I have code that works fine when I install the extension of the output file, for example, ".xlsx", but when I change it to ".xls", I have a window before opening the file in MSExcel, this file is incorrect ( the file format is incorrect) and then a lot of incorrect encoding characters (e.g. Japanese, etc.).
Has anyone had this problem? Is there a solution?
_currentContext.Response.Clear(); _currentContext.Response.ClearContent(); _currentContext.Response.ClearHeaders(); _currentContext.Response.AddHeader("content-disposition", "attachment; filename=FileName.xlsx"); _currentContext.Response.ContentEncoding = System.Text.Encoding.UTF8; _currentContext.Response.ContentType = "application/ms-excel"; _currentContext.Response.AddHeader("Content-Transfer-Encoding", "binary"); _currentContext.Response.BinaryWrite(_package.GetAsByteArray()); _currentContext.Response.Flush(); _currentContext.Response.End();
One moment - when I export it to xls on my local computer, everything works fine. When I try to use it on a remote server, I can correctly export it only to the xlsx extension.
FSou1 source share