我试图创建一个使用C#中的XLS文件这样创建并保存的XLS文件在C#
protected void ExportToExcel(DataSet dset, int TableIndex, HttpResponse Respone, string Felename)
{
Respone.Clear();
Respone.Charset = "";
Respone.ContentType = "application/vnd.ms-excel";
Respone.AddHeader("content-disposition", "attachment; filename=" + Felename + ".xls");
System.IO.StringWriter sw = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(sw);
GridView gv = new GridView();
gv.DataSource = dset.Tables[TableIndex];
gv.DataBind();
gv.RenderControl(hw);
Respone.Write(sw.ToString());
Respone.End();
}
这是为我工作的罚款。但它是在成功完成后创建xls文件的开放。但是我想将文件保存在我的文件夹中,而无需打开并询问我的许可证。
我如何能自动保存..
在此先感谢
这SO线程,【答案这里链接](http://stackoverflow.com/questions/871115/what-is-the-best-and-fastest-way-to -write-into-excel-file-using-c/871142#871142)是一种好方法。 – kenny 2009-10-09 14:19:06