Click here to Skip to main content
15,886,036 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Friends,

I am exporting my data to excel by rendering html to excel format. But when exporting large data, then the data doesn't get exported instead an exception occurs like:- "system.outofmemoryexception ".

The excel file size is 23.1 MB for around 7000+ records. In some PC it is working fine but at client side it is giving the above mentioned error.

My code is:-
Dim attachment As String = "attachment; filename=OutstandingReport.xls"
Response.ClearContent()
Response.AddHeader("content-disposition", attachment)
Response.ContentType = "application/ms-excel"
ReportTable.RenderControl(htw)
Response.Write(sw.ToString())
Response.Flush() 'Added By: Varun Sareen on 17th June, 2013
Response.[End]()


Here the ReportTable is the HTMl code with data.

Please help me in this regard if any one is having a proper solution.

Thanks & Regards

Varun Sareen
Posted
Updated 17-Jun-13 1:46am
v2
Comments
Simon_Whale 17-Jun-13 7:54am    
what is the size of the data that you called form the database is that greater than 7000 records?
Varun Sareen 17-Jun-13 8:28am    
yes around 7000 or it could be more. The size of the file being generated is around 21 to 23 MB

If you configure your website properly, your clients will not see the details of server side errors like this. As the export is happening on the server side, this has nothing to do with memory on the client side, it may have to do with the server sometimes having enough RAM and sometimes not.

Buy more RAM.
 
Share this answer
 
Comments
Varun Sareen 26-Jun-13 10:37am    
thanks dear
This kind of problem happended when you have your application continuously running in visual studio... due to which memory got increasingly fill and this exception got thrown.. so If you are providing services to client.. deploy application over IIS or some server via physical path.. and dont let the Visual Studio run continuously....



This is what I Experienced.. so sharing it... hope will help.

Regards,

:)
 
Share this answer
 
Comments
Varun Sareen 26-Jun-13 10:37am    
thanks dear
VICK 27-Jun-13 4:34am    
U r Welcome... :)

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