如何通过C#中的Web应用程序将大型数据从数据库导出到Excel [英] How to export large data from database to excel through web application in c#

查看:89
本文介绍了如何通过C#中的Web应用程序将大型数据从数据库导出到Excel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何通过C#中的Web应用程序将数据库中的大数据(约30万条记录)导出到Excel?时间限制应该更精确...?

解决方案

我不认为有可能将30万条记录的数据导出到Excel,因为Excel具有最多65''536行.因此,唯一的方法是在同一excel文件中添加下一张工作表.

这是将数据集导出到多个Excel工作表的绝佳示例-将数据集导出到多个Excel工作表 [ ^ ]


如果您的最终用户使用的是Excel 2003或更早版本,则需要将输出分为一个单独的工作簿中的
  • 几个不同的工作簿
    • 几个不同的工作表
基于某些逻辑拆分-例如产品类型(也许您的Web应用可以要求用户拆分).

如果他们使用的是Excel 2007,则该限制将大大消失 MSDN [ ^ ],但是您需要请记住,如果所有数据都在一个工作簿中(使用多个工作表或Excel 2007方法),则将需要很长时间才能打开.

无论采用哪种方法,我都建议您设计一个可以接受请求的Web前端,然后在完成后触发异步过程以导出数据并将其发送给它们(也许通过电子邮件压缩). /blockquote>

尝试一下


http://aspnetlibrary.com/articledetails.aspx?article=How- to-export-a-GridView-to-Excel [ ^ ]



http://www.c-sharpcorner.com/uploadfile/dipalchoksi/exportxl_asp2_dc11032006003657am/exportxl_asp /a> [^ ]



不要忘记这样做.

公共重写void VerifyRenderingInServerForm(Control control)
{
//确认为
呈现了HtmlForm控件 在运行时指定ASP.NET服务器控件.
}



首先绑定gridview并将其导出到excel中,上面的链接可能对您有帮助


How to export large data(about 3lakh records) from database to excel through web application in c#? The time limit should be more precise...?

解决方案

I do not think it is possible to export data of 3 lakh records to excel as Excel has the capability to have maximum 65''536 rows. So, the only way is to add in next sheet in the same excel file.

Here is wonderful example for exporting dataset to mulitple excel sheets - Export DataSet to Multiple Excel Sheets[^]


If your end users are using Excel 2003 or older, you are going to need to split the output into either
  • several different workbooks
    • several different worksheets in a single workbook
based on some logical split - e.g. product type(maybe your web app can ask user for split).

If they are using Excel 2007 this restriction largely goes away MSDN[^], however you need to remember that if all the data is in one workbook (using the several worksheets, or Excel 2007 approach) it will take a long time to open.

Regardless of which approach you take I would suggest that you design a web front end that accepts the request, which then fires an asynchronous process to export the data and send it to them (perhaps zipped via e-mail) once it has completed.


Try this


http://aspnetlibrary.com/articledetails.aspx?article=How-to-export-a-GridView-to-Excel[^]



http://www.c-sharpcorner.com/uploadfile/dipalchoksi/exportxl_asp2_dc11032006003657am/exportxl_asp2_dc.aspx[^]



dont forget to do this.

public override void VerifyRenderingInServerForm(Control control)
{
// Confirms that an HtmlForm control is rendered for the
specified ASP.NET server control at run time.
}



First of all bind gridview and export it into excel the above link might help you


这篇关于如何通过C#中的Web应用程序将大型数据从数据库导出到Excel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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