I have this code to extract a table to a computer in a .xls file:
HttpResponse response = HttpContext.Current.Response;
response.Clear();
response.AddHeader("Content-Disposition", String.Format("Attachment;Filename=file.xls", ));
response.Buffer = true;
response.ContentEncoding = System.Text.Encoding.Default;
response.ContentType = "application/vnd.ms-excel";
response.Write(excelTable);
response.End();
And I saw that this is not a real .xls file. I can open it in Notepad and see my standard html table codes.
Now I understand that the definition is ContentTypenot enough. So what else can I do to create a clean .xls or .xlsx file? Or should I use Excel libraries like OpenXML, Interop, etc.?
source
share