The way to export to the Excel document is probably like this.
DIM I as INTEGER, J AS INTEGER
DIM MyExcel as new excel.application
Dim MyBook As New Excel.Workbook
DIM mysheet as new excel.worksheet
Set mybook = myexcel.Workbooks.add 'Add a new BOOK
Set mysheet = mybook.worksheets.add 'Add a new Sheet
'For i = 1 to myres.recordcount
'For j = 1 to myres.fields.count
'mysheet.cells (i, j) = myres.fields.Item (j - 1) .value
'IF (i * j) MOD 500 = 0 THEN
'Doevents
'End if
'Next J
'myres.movenext
'Next I
MyExcel.visible = true
Mybook.saves (m_excelname) 'Save File
This method has no mistake, but if the amount of data is large, trouble is coming, the program is not responding for a long time.
The key is loop, give my code.
Suppose the defined record named Myres
DIM MyExcel as new excel.application
Dim MyBook As New Excel.Workbook
DIM mysheet as new excel.worksheet
Set mybook = myexcel.Workbooks.add 'Add a new BOOK
Set mysheet = mybook.worksheets.add 'Add a new Sheet
MyExcel.visible = true
MySheet.cells.copyFromRecordset Myres
Mybook.saves (m_excelname) 'Save File
Using this code, it can be greatly shortened, and more than 8,000 records need to be more than 2 points.
The second method is only about 4 seconds, and you can experiment in person, the above results test platform is Win98 Excel2000