You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

45 lines
1.8 KiB

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("<style type=text/css>");
HttpContext.Current.Response.Write("td{mso-number-format:\"\\@\";}");
HttpContext.Current.Response.Write("</style>");
HttpContext.Current.Response.Write(strData);
HttpContext.Current.Response.End();
}
}
}