导出到excel时抛出系统outofmemoryexception [英] system outofmemoryexception was thrown while export to excel

查看:946
本文介绍了导出到excel时抛出系统outofmemoryexception的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友们,



我通过将html渲染为excel格式将我的数据导出到excel。但是在导出大数据时,数据不会被导出而是发生异常,如: - system.outofmemoryexception



对于大约7000多条记录,excel文件大小为23.1 MB。在某些PC上工作正常,但在客户端则出现上述错误。



我的代码是: -

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]()





这里的ReportTable是包含数据的HTMl代码。



如果有人有合适的解决方案,请帮助我。



谢谢&问候



Varun Sareen



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

推荐答案

如果你正确配置你的网站,你的客户将看不到详细信息像这样的服务器端错误。由于导出是在服务器端进行的,这与客户端的内存无关,它可能与服务器有时有足够的RAM而有时没有。



购买更多内存。
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.


当您的应用程序在Visual Studio中持续运行时,这种问题就会出现...由于内存越来越多,内存越来越多,并且抛出了这个异常。所以如果你正在为客户提供服务..通过物理路径在IIS或某些服务器上部署应用程序..并且不要让Visual Studio连续运行....







这就是我的经历..所以分享吧...希望会有所帮助。



此致,



:)
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,

:)


这篇关于导出到excel时抛出系统outofmemoryexception的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆