我注意到,此警告消息總是每次我打開我的web應用程序彈出警告
filename.xls導出Excel文件時彈出,在與文件擴展名指定的格式不同 。 驗證文件不是 損壞.....
這裏使用的代碼:
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", "Single_Raw.xls"));
HttpContext.Current.Response.ContentType = "application/ms-excel";
using (StringWriter sw = new StringWriter())
{
using (HtmlTextWriter htw = new HtmlTextWriter(sw))
{
Table tb = new Table();
TableRow tr = new TableRow();
tr.Cells.Add((rawRow((lblPOR1.Text.Substring(0, 4)), (lblPOR1.Text.Substring(5, 3)), (lblPOR1.Text.Substring(9, 3)), lblPNL.Text.ToString())));
TableCell cell3 = new TableCell();
cell3.Text = " ";
TableRow tr2 = new TableRow();
tr2.Cells.Add((rawRow((lblPOR2.Text.Substring(0, 4)), (lblPOR2.Text.Substring(5, 3)), (lblPOR2.Text.Substring(9, 3)), lblPNL.Text.ToString())));
tb.Rows.Add(tr);
tb.Rows.Add(tr2);
tb.RenderControl(htw);
HttpContext.Current.Response.Write(sw.ToString());
HttpContext.Current.Response.End();
}
}
警告仍顯示 – 2011-05-19 02:53:07