且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

出口数据集Excel表格在asp.net C#

更新时间:2022-10-31 18:44:04

首先你的函数启动流媒体内容。

First of all your function start streaming content

 Response.ContentType = "application/vnd.ms-excel";
                Response.AppendHeader("Content-Disposition", "attachment; filename=" + filename + "");

最终用户和最终它

to end user and END it with

Response.End();

此外,如果你解决这个问题你code意志产品4 Excel文件。

Moreover if you fix this your code will product 4 excel files.

有一个现有的code对堆栈溢出创建Excel表:How从数据表增加额外的工作表到Excel
你将不得不做出的唯一改变将节能XLSX流和该流传输给用户。

There is an existing code for creating Excel sheets on stack overflow: How to add additional worksheets to an Excel from DataTable The only change you will have to made will be saving xlsx to stream and transmit this stream to user.