Dim strFile As String = ofdSelectExcel.FileName
Dim excelApp As Excel.Application
Dim excelWork As Excel.Workbook
Dim excelSheet As Excel.Worksheet
excelApp = New Excel.Application
excelWork = excelApp.Workbooks.Open(strFile)
Dim sheetNum As Integer = 1
For i As Integer = 0 To UBound(WriteArr)
If ((i + 1) Mod 20) = 1 Then
If sheetNum > excelWork.Worksheets.Count Then
excelSheet = excelWork.Sheets.Add(, excelWork.Worksheets(sheetNum - 1))
Else
excelSheet = excelWork.Worksheets.Item(sheetNum)
End If
Else
excelSheet = excelWork.Worksheets.Item(sheetNum)
End If
excelSheet.Cells(((i + 1) - 20 * (sheetNum - 1)), 1) = i + 1
If ((i + 1) Mod 20) = 0 Then
sheetNum += 1
End If
Next
还有个问题,就是怎样将40行20列的数组前20行导入到第一个sheet,后20行导入到第二个sheet?谢谢!
[Quote=引用 1 楼 的回复:]
Dim strFile As String = ofdSelectExcel.FileName
Dim excelApp As Excel.Application
Dim excelWork As Excel.Workbook
Dim excelSheet As Excel.Worksheet
excelApp = New Excel.Application
exce……
[/Quote]