以.zip格式导出到Excel [英] Export to Excel as in .zip format
本文介绍了以.zip格式导出到Excel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经完成了将数据集导出到Excel Sheets中的代码,但是现在想将文件下载到C#asp.net中的zip文件中吗?该怎么做?
I have done the code for esport the DataSet into the Excel Sheets, but now would like to download the file into a zip in C# asp.net? How to do that?
private void btnDownload_Click(object sender, System.EventArgs e)
{
Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=test.xls");
Response.Charset = "";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "application/vnd.xls";
dgReg.EnableViewState = true;
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
dgReg.RenderControl(htmlWrite);
Response.Write("<meta http-equiv=Content-Type content=\"text/html; charset=utf-8\">");
Response.Write(stringWrite.ToString());
Response.End();
}
推荐答案
有很多zip库,这里是一对:
SharpZipLib
Dotnetzip
There are a lot of zip libraries here is a couple :
SharpZipLib
Dotnetzip
这篇关于以.zip格式导出到Excel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文