ASP.NET MVC在zip文件中返回xls文件 [英] ASP.NET MVC returning an xls file inside an zip file
本文介绍了ASP.NET MVC在zip文件中返回xls文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个返回一个xls文件的asp.net mvc操作:
I have an asp.net mvc action that returns an xls file:
public void Excel(string filename)
{
DAOSolicitacao dao = new DAOSolicitacao();
System.Threading.Thread.Sleep(5000);
var products = dao.GetSolicitacoes();
var grid = new GridView();
grid.DataSource = products;
grid.DataBind();
Response.ClearContent();
Response.Buffer = true;
Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", filename));
Response.ContentType = "application/ms-excel";
Response.Charset = "";
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
grid.RenderControl(htw);
Response.Output.Write(sw.ToString());
Response.Flush();
Response.End();
}
如何使此xls文件返回到zip文件中?
How can I make this xls file return into an zip file ?
推荐答案
Google!是你的朋友!
Google! Is your friend!
这篇关于ASP.NET MVC在zip文件中返回xls文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文