excle直接以某个文件名保存到指定文件夹
从DS导出数据到Excel,无需打开Excel,直接填充并分配文件名保存到指定路径文件夹... --------------------编程问答-------------------- 帮帮忙啊--------------------编程问答-------------------- Excel中不是有个SaveAs的方法啊,直接调用就可以了啊 --------------------编程问答-------------------- string strFullFileName = Server.MapPath("." + "/tset.xls");
FileInfo DownloadFile = new FileInfo(strFullFileName);
Response.Clear();
Response.ClearHeaders();
Response.Buffer = false;
Response.ContentType = "application/vnd.ms-excel";
Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(DownloadFile.FullName, System.Text.Encoding.UTF8));
Response.AppendHeader("Content-Length", DownloadFile.Length.ToString());
Response.WriteFile(DownloadFile.FullName);
Response.Flush();
Response.End(); --------------------编程问答-------------------- Response.Charset = "GB2312";
Response.ContentEncoding = Encoding.UTF7;
Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(strFileName + ".xls", Encoding.UTF8).ToString());//
Response.ContentType = "application/ms-excel";
this.EnableViewState = false;
StringWriter tw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(tw);
gridview1.RenderControl(hw);//
Response.Write(tw.ToString());
Response.End(); --------------------编程问答-------------------- 可能我没说清楚,excle是没有生成的,就是说将未生成的excle以某一名字保存到文件夹
补充:.NET技术 , ASP.NET