Whenever you are willing to send an Excel in-memory file over internet, in your ASP/ASP.NET code, make sure to consider the following :
1) Ensuring proper buffer size is sent :
// fileBytes is our in-memory file, generated by xlsgen, ready to be sent over the wire
// C#
Response.ContentType = "application/vnd.ms-excel";
Response.AppendHeader("Content-Disposition", "attachment; filename=\\"sample.xls\\"");
Response.BinaryWrite(fileBytes);
Response.End();
// VB VB.NET
Response.ContentType = "application/vnd.ms-excel"
Response.AppendHeader("Content-Disposition", "attachment; filename=""sample.xls""")
Response.BinaryWrite(fileBytes)
Response.End
2) Ensuring proper content type tagging :
.XLS ==> application/vnd.ms-excel
.XLSX ==> application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
.XLSM ==> application/vnd.ms-excel.sheet.macroEnabled.12
.XLTX ==> application/vnd.openxmlformats-officedocument.spreadsheetml.template
.XLTM ==> application/vnd.ms-excel.template.macroEnabled.12
.XLAM ==> application/vnd.ms-excel.addin.macroEnabled.12