我已经成功导出了excel文件,但问题是导出的excel文件没有在android中打开,而我已经看到很多应用程序将文件导出到excel并且相同的文件在android上打开,那么为什么我的导出文件没有?
//filled dt sucessfully
using (XLWorkbook wb = new XLWorkbook())
{
wb.Worksheets.Add(dt);
Response.Buffer = true;
using (MemoryStream MyMemoryStream = new MemoryStream())
{
wb.SaveAs(MyMemoryStream);
//response starts
Response.Cache.SetCacheability(HttpCacheability.Private);
Response.CacheControl = "private";
Response.Charset = System.Text.UTF8Encoding.UTF8.WebName;
Response.ContentEncoding = System.Text.UTF8Encoding.UTF8;
Response.AppendHeader("Content-Length", MyMemoryStream.Length.ToString());
Response.AppendHeader("Pragma", "cache");
Response.AppendHeader("Expires", "60");
Response.AppendHeader("Content-Disposition",
"attachment; " +
"filename=\"Reports.xlsx\"; " +
"size=" + MyMemoryStream.Length.ToString() + "; " +
"creation-date=" + DateTime.Now.ToString() + "; " +
"modification-date=" + DateTime.Now.ToString() + "; " +
"read-date=" + DateTime.Now.ToString());
Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
MyMemoryStream.WriteTo(Response.OutputStream);
Response.Flush();
Response.End();
}
}