I just want to stream a xlsx file using NPOI SXSSF method. But when I download streamed excel file in opening pops up message:
Excel found unreadable content in 'MyExcelFile.xlsx'. Do you want to recover the contents of the workbook? If you trust the source of this workbook, click Yes.
My code:
Response.Headers.Add("Content-disposition", "attachment; filename=\"MyExce.xlsx\"");
Response.Headers.Add("Content-type", "octet-stream");
SXSSFWorkbook wb = new SXSSFWorkbook();
SXSSFSheet sheet = (SXSSFSheet)wb.CreateSheet("FirstSheet");
IRow row = sheet.CreateRow(0);
ICell cell = row.CreateCell(0);
cell.SetCellValue("firstCell");
//Write file to output stream
wb.Write(Response.Body);
wb.Close();
Response.Body.Flush();
What am I doing wrong?