* LTE 65535 recs oExcel = createobject("Excel.application") Copy to temp type fox2x With oExcel .workbooks.Open(sys(5)+curdir()+"temp.dbf") .visible = .t. Endwith
* GT 65535 Clear all * Create a test cursor Create cursor testcursor (Rcno i,cType c(10), nType i, dType d) Rand(-1) For ix = 1 to 200000 && Create 200000 recs cursor Insert into testcursor values ; (recco()+1,sys(2015), int(rand()*1000), date()-int(rand()*100)) Endfor Set sysformats on Set safety off lnTotal = reccount() Wait window nowait "Pls wait sending data to Excel..." Start = seconds() oExcel = createobject("Excel.application") With oExcel .workbooks.add && Add a new workbook lnMaxRows = .ActiveWorkBook.ActiveSheet.Rows.Count && Get max row count .ActiveWorkBook.Close(.f.) && Close no save lnNeededSheets = ceiling( lnTotal / lnMaxRows ) && 1 row header ? "Total Pages : "+padr(lnNeededSheets,3," ") Copy to temp for recno()<=lnMaxRows-1 type fox2x && One for header .workbooks.open(sys(5)+curdir()+"temp") && Open saved ? "Page no : 1/"+; padr(lnNeededSheets,3," ")+ ; " Elapsed : ",seconds() - start If lnNeededSheets > 1 With .ActiveWorkBook lnCurrentSheetCount = .sheets.count If lnNeededSheets > lnCurrentSheetCount .sheets.add(,.sheets(lnCurrentSheetCount),; lnNeededSheets - lnCurrentSheetCount) && Add new sheets after old ones Endif For ix = 2 to lnNeededSheets With .sheets.item(ix) .name = "Page "+padl(ix,3,"0") .activate =InsertGroup(ix, lnMaxRows) Endwith Endfor .sheets.item(1).activate Endwith Endif .visible = .t. Endwith ? "Total Elapsed : ",seconds() - start Function InsertGroup Lparameters tnSheetNumber, tnMaxRows Local lnPasteStart, lcTempFile lnPasteStart = ( tnSheetNumber - 1 ) * tnMaxRows lcTempFile = sys(2015)+".txt" Copy to (lcTempFile) delimited with TAB for between(recno(),lnPasteStart,lnPasteStart+tnMaxRows) _Cliptext = filetostr(lcTempFile) Erase (lcTempFile) *expression.TextToColumns(Destination, DataType, TextQualifier, ConsecutiveDelimiter, Tab, Semicolon, Comma, Space, Other, OtherChar, FieldInfo, DecimalSeparator, ThousandsSeparator) With oExcel .workbooks(1).sheets.Item(tnSheetNumber).activate .workbooks(1).ActiveSheet.Range("A1").PasteSpecial() _Cliptext = "" && Empty clipboard ? "Pasted from ", lnPasteStart,' to ',min(lnPasteStart+tnMaxRows-1, reccount()), "elapsed", seconds() - start Endwith ? "Page no : "+; padl(tnSheetNumber,3," ")+; "/"+; padr(lnNeededSheets,3," ")+ ; " Elapsed : ",seconds() - startCetin