sql server - Fast Way To Export DataSet To Excel in VB.Net -


i need export lot (nearly million) of data everyday sqlserver excel. data being processed through stored procedure put them on dataset , tried export using code:

` private sub exporttoexcel(byval dttemp system.data.datatable, byval filepath string) dim strfilename string = filepath

    dim _excel new excel.application     dim wbook excel.workbook     dim wsheet excel.worksheet      wbook = _excel.workbooks.add()     wsheet = wbook.activesheet()      dim dt system.data.datatable = dttemp     dim dc system.data.datacolumn     dim dr system.data.datarow     dim colindex integer = 0     dim rowindex integer = 0      each dc in dt.columns         colindex = colindex + 1         wsheet.cells(1, colindex) = dc.columnname     next      each dr in dt.rows         rowindex = rowindex + 1         colindex = 0         each dc in dt.columns             colindex = colindex + 1             wsheet.cells(rowindex + 1, colindex) = dr(dc.columnname)         next     next     wsheet.columns.autofit()     wbook.saveas(strfilename)      releaseobject(wsheet)     wbook.close(false)     releaseobject(wbook)     _excel.quit()     releaseobject(_excel)     gc.collect() end sub` 

is there faster way this? how dataset clipboard paste excel?

one way save dataset xml file:

mydataset.writexml("c:\file.xml") 

Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -