我試圖創建一個使用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