2
我想解析一個大尺寸的文本文件,文本文件的大小是257MB。我使用listview查看解析數據後,我解析大文件,我想保存爲excel文件,但每次我點擊按鈕保存爲excel文件,我會得到這個錯誤「運行時6溢出」運行時錯誤6 - OVERFLOW
下面是我的代碼保存解析數據爲Excel文件
Private Sub cmd_save_excel_Click()
Dim ExcelObj As Object
Dim ExcelBook As Object
Dim ExcelSheet As Object
Dim i As Integer
Set ExcelObj = New Excel.Application
Set ExcelBook = ExcelObj.Workbooks.Add
Set ExcelSheet = ExcelBook.Worksheets(1)
With ExcelSheet
For i = 1 To ListView1.ListItems.Count
'.Cells(i, 1) = ListView1.ListItems(i).Text
.Cells(i, 1) = ListView1.ListItems(i).SubItems(1)
.Cells(i, 2) = ListView1.ListItems(i).SubItems(2)
.Cells(i, 3) = ListView1.ListItems(i).SubItems(3)
.Cells(i, 4) = ListView1.ListItems(i).SubItems(4)
.Cells(i, 5) = ListView1.ListItems(i).SubItems(5)
.Cells(i, 6) = ListView1.ListItems(i).SubItems(6)
Next
End With
ExcelObj.Visible = True
Set ExcelSheet = Nothing
Set ExcelBook = Nothing
Set ExcelObj = Nothing
End Sub
我需要你的幫助!預先感謝您..
'Dim i as Long'。 – GSerg
好吧,謝謝GSerg :) – bebebe
@JustinDavies你改變了OP的代碼,並在建議的答案中編輯,就好像它最初是在代碼中一樣。請不要那樣做。 – GSerg