Click here to Skip to main content
15,894,405 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,

I have a procedure which returns more than 5lak records; and i need to export it into excel or any other format.I tried with crystal report, but failed;Also tried exporting from dataset to excel and datagrid to excel, but failed.
Please help me its very urgent..
Please find below the code I used to export directly from dataset to excel.

VB
Dim ds As DataSet
Dim i, j As Integer
ds = objGPBLL.getGridView()

Dim xlApp As Excel.Application
Dim xlWorkBook As Excel.Workbook
Dim xlWorkSheet As Excel.Worksheet
Dim misValue As Object = System.Reflection.Missing.Value

xlApp = New Excel.ApplicationClass
xlWorkBook = xlApp.Workbooks.Add(misValue)
xlWorkSheet = xlWorkBook.Sheets("sheet1")

For i = 0 To ds.Tables(0).Rows.Count - 1
    For j = 0 To ds.Tables(0).Columns.Count - 1
        xlWorkSheet.Cells(i + 1, j + 1) = ds.Tables(0).Rows(i).Item(j)
    Next
Next

xlWorkSheet.SaveAs("D:\vbexcel.xls")
xlWorkBook.Close()
xlApp.Quit()
MsgBox("You can find the file D:\vbexcel.xls")



Thanks in advance..
Posted
Updated 9-Jan-12 18:25pm
v2
Comments
Suresh Suthar 9-Jan-12 8:42am    
Failed? What problem, any error?
Member 8550673 9-Jan-12 8:45am    
from crystal report, only 65000 records are coming for excel2007 and above; for datagrid, it showed system out of memory exception and for dataset to excel, its taking long time..but no result and finally showing cannot display webpage.
Pls help me out with any code.
Simon_Whale 9-Jan-12 9:59am    
with your dataset code, update your question using the improve question and we may be able to help you identify problems / bottle necks in your code

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900