如何通过单击按钮即时生成excel文件。 [英] How to generate excel files on the fly, on click of a button.

查看:173
本文介绍了如何通过单击按钮即时生成excel文件。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在asp.net中有一个web应用程序,当我在网页上点击一个按钮时我必须生成一个excel文件.excel文件还包含各个单元格的公式,因此我使用了interop来创建excel文件。我完成的步骤是:

1.使用互操作创建所需的excel文件。

2.给它一个随机名称并将其保存在某个文件夹中。

3.设置此文件的某些超链接的导航网址。

4.然后用户必须单击超链接才能获取文件。

5.调度程序删除存储在该文件夹中的excel文件。



现在,我想以某种方式实现这一点,以便即时生成excel文件单击按钮并作为附件发送到客户端浏览器。





请在asp.net中建议一些方法。

I have a web application in asp.net, wherein I have to generate a excel file when a button is clicked on the web page.The excel file also contains formulae at various cells, therefore I have used interop to create the excel file. The steps done by me are:
1. create required excel file using interop.
2. give it a random name and save it in some folder.
3. Set the navigate url of some hyperlink to this file.
4. Then user have to click the hyperlink to get the file.
5. the excel file stored in the folder is removed by a scheduler program.

Now, I want to implement this in a way so that the excel file is generated on the fly on the click of a button and send to the client browser as attachment.


Please suggest some method to do this in asp.net.

推荐答案

参见本页:

http://www.ehow.com/how_6071961_create-excel-file-asp-net.html [ ^ ]


It pro更好地使用NPOI - > https://npoi.codeplex.com/ [ ^ ]



这样你就可以在内存中生成一个新的excel文件,并将其发送给用户甚至将它保存在某个地方。
It probably better to use NPOI --> https://npoi.codeplex.com/[^]

This way you can generate a new excel file in memory and send it to a user without even saving it somewhere.


请参考这个链接,这可能对你有帮助

在asp.net和c#中将Gridview导出到Excel [ ^ ]
Please refer this link which might help you
Export Gridview to Excel in asp.net and c#[^]


这篇关于如何通过单击按钮即时生成excel文件。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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