gridview输出excel ,如何指定路径,急?
下列代码,如果想指定输出路径,如何做
Response.Clear();
Response.Buffer = true;
Response.Charset = "GB2312 ";
Response.AppendHeader( "Content-Disposition ", "attachment;filename=FileName.xls ");
// 如果设置为 GetEncoding( "GB2312 ");导出的文件将会出现乱码!!!
Response.ContentEncoding = System.Text.Encoding.UTF7;
Response.ContentType = "application/ms-excel ";//设置输出文件类型为excel文件。
System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
t.RenderControl(oHtmlTextWriter);
Response.Output.Write(oStringWriter.ToString());
Response.Flush();
Response.End();
------解决方案--------------------楼主的该输出方式,并不能指定路径,因为它直接输出到客户端的临时文件夹!
就像我们从网上下载的文件,没有指定文件夹的吧,都是下载保存的时候才指定位置.