简体   繁体   English

从 web 页面按钮使用 Pivot 表创建 Excel 文件

[英]Create Excel file with Pivot table from a web page button

I would like to create an excel file on clicking a button on a web page created in .NET.我想通过单击在 .NET 中创建的 web 页面上的按钮来创建 excel 文件。 This excel file would have multiple pivot tables.这个 excel 文件将有多个 pivot 表。 Please let me know if there is a way to create the excel file on button click and if it really necessary to save the file to create the pivot tables.请让我知道是否有一种方法可以在单击按钮时创建 excel 文件,以及是否确实需要保存文件以创建 pivot 表。 I have created excel file with pivot table on a console application but have not done that in a web application.can the file be created without actually saving the file and giving the user the flexibility to Save/Open it?我已经在控制台应用程序上创建了带有 pivot 表的 excel 文件,但在 web 应用程序中没有这样做。可以在不实际保存文件并给予用户保存/打开灵活性的情况下创建文件吗?

Thanks,谢谢,

Since you shouldn't install Excel on a server, your best option would be to create and/or manipulate an Excel file using http://en.wikipedia.org/wiki/Office_Open_XML , which is the documented XLSX format.由于您不应该在服务器上安装 Excel,因此您最好的选择是使用http://en.wikipedia.org/wiki格式创建和/或操作 Excel 文件You can use the Open XML SDK 2.0 for Microsoft Office to make your life easier.您可以使用Microsoft Office 的 Open XML SDK 2.0让您的生活更轻松。

Once the Excel file has been created/manipulated you can either save it to a temporary location on the server, then return the file via request, and delete the file.创建/操作 Excel 文件后,您可以将其保存到服务器上的临时位置,然后通过请求返回文件,然后删除文件。 This is assuming you use IIS and either WebForms or MVC.这是假设您使用 IIS 和 WebForms 或 MVC。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM