Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Fri Sep 06, 2013 5:26 am

Hi

We use the following code to export data from SQL Server to Excel on the web server which then sends down to users.

When running on a relatively large dataset e.g. 25000 lines, then it takes half an hour.

We know the database query is not the problem because if we run it manually, it only takes 4 seconds.

Please advise if there is a more efficient way than what I am doing below.

Thanks
Fred


// retrieve data into DataSet from database into dsExport

Workbook workbook = new Workbook();
workbook.Version = Spire.Xls.ExcelVersion.Version97to2003;
Worksheet worksheet = workbook.Worksheets[0];
worksheet.InsertDataTable(dsExport.Tables[0], true, 1, 1);
for (int i = 1; i <= worksheet.Columns.Length; i++)
{
worksheet.AutoFitColumn(i);
}
workbook.SaveToHttpResponse("export.xls", Response);
Response.Flush();

fso
 
Posts: 2
Joined: Wed Feb 16, 2011 5:20 pm

Fri Sep 06, 2013 9:06 am

Hello Fred,

Thanks for your inquiry.

Sorry that we couldn't reproduced the issue with the difference data, could you please provide us your Data or the generated xls by email if convenience? It would be helpful for us to investigate the issue.

If there are any questions, welcome to get it back to us.

Thanks,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Return to Spire.XLS