嗨我已經使用ClosedXML.dll創建了一個Excel文件,當我要打開該文件時,它顯示「Excel發現不可讀的內容」消息。我的文件內容有瑞典文。我不知道根源是什麼?有什麼方法可以設置語言嗎?如何刪除該警告,請幫助我。這是代碼捕捉。ClosedXML.dll打開Excel文件顯示錯誤「Excel發現無法讀取的內容」
using (XLWorkbook wb = new XLWorkbook())
{
wb.Worksheets.Add(dt); //dt is DataTable
Response.Clear();
Response.ClearHeaders();
Response.Buffer = true;
Response.Charset = "";
Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
Response.AddHeader("content-disposition", "attachment;filename="+fileName+".xlsx");
Response.ContentEncoding = Encoding.UTF8;
using (MemoryStream MyMemoryStream = new MemoryStream())
{
MyMemoryStream.Capacity = (int)MyMemoryStream.Length;
wb.SaveAs(MyMemoryStream);
MyMemoryStream.WriteTo(Response.OutputStream);
Response.Flush();
Response.End();
}
}