ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Writing to excel is very slow (https://www.excelbanter.com/excel-discussion-misc-queries/38498-writing-excel-very-slow.html)

minaz_khan

Writing to excel is very slow
 

I am writing a code in VB.NET and writing to it through a dataset.
But for every 25 seconds it writes only 100 rows to the excel.

Can any1 please comment on this.

Here is a piece of the code
For Each drXML As DataRowView In ViewToSort
rowCnt += 1
totCnt += 1

If rowCnt = 1 Then
objExcelWS = objExcelWB.Worksheets(sheetCnt)

For colCnt = 1 To xlsDS.Tables(0).Columns.Count
objExcelWS.Cells(rowCnt, colCnt) =
xlsDS.Tables(0).Columns(colCnt - 1).ColumnName
Next
End If

For colCnt = 1 To xlsDS.Tables(0).Columns.Count
'objExcelWS.Cells(rowCnt + 1, colCnt) = "'" &
Format(drXML(colCnt - 1).ToString())
objExcelWS.Cells(rowCnt + 1, colCnt) = drXML(colCnt
- 1).ToString()
Next

'if row count reaches 65K and not end of dataset, close
this worksheet
If rowCnt = 65000 And totCnt <
xlsDS.Tables(0).Rows.Count Then
rowCnt = 0
sheetCnt += 1
End If

Next


--
minaz_khan
------------------------------------------------------------------------
minaz_khan's Profile: http://www.excelforum.com/member.php...o&userid=25875
View this thread: http://www.excelforum.com/showthread...hreadid=392591



All times are GMT +1. The time now is 07:17 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com