Dim NewXls As Excel.Application
Dim NewBook As Excel.Workbook
Dim NewSheet As Excel.Worksheet
'
Set NewXls = New Excel.Application '创建 EXCEL 应用程序,打开 EXCEL2000
Set NewBook = NewXls.Workbooks.Open(CurrentProject.Path & "\Demo.xls") '创建工作簿
nSheetCount = NewBook.Worksheets.Count
sArrFieldsName = Array("尺码", "颜色", "数量")
Set rs2 = Nothing
rs2.CursorLocation = adUseClient
rs2.Open "select * from 1 ", db2, adOpenStatic, adLockPessimistic
Set NewSheet = NewBook.Worksheets(1) '创建工作表
For AAA = 2 To 10 '尺码行数
For BBB = 1 To 6 '颜色列数
If NewSheet.Cells(AAA + 1, 1) <> "" Then
If NewSheet.Cells(2, BBB + 1) <> "" Then
If Nz(NewSheet.Cells(AAA + 1, BBB + 1)) <> 0 Then
rs2.AddNew
rs2!尺码 = NewSheet.Cells(AAA + 1, 1).Value
rs2!颜色 = NewSheet.Cells(2, BBB + 1).Value
rs2!数量 = NewSheet.Cells(AAA + 1, BBB + 1).Value
End If
End If
End If
Next
Next