using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace OT.Web { public partial class ExpFile : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { string strData = Request["Data"]; string strFileName = Request["FileName"]; if (Context.Items["Data"] != null) { strData = Context.Items["Data"].ToString(); } if (Context.Items["FileName"] != null) { strFileName = Context.Items["FileName"].ToString(); } if (Session["Data"] != null) { strData = Session["Data"].ToString(); } if (Session["FileName"] != null) { strFileName = Session["FileName"].ToString(); } HttpContext.Current.Response.Clear(); HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache); HttpContext.Current.Response.ContentType = "application/vnd.xls"; HttpContext.Current.Response.AddHeader("content-disposition", "attachment;filename=" + strFileName); HttpContext.Current.Response.AddHeader("mata", "http-equiv=Content-Type content=text/html;charset=utf-8"); //修正匯出後檔案格式問題,例如電話開頭0931變成931, HttpContext.Current.Response.Write(""); HttpContext.Current.Response.Write(strData); HttpContext.Current.Response.End(); } } }