my function which i want to format is as follows
private void GenerateXLSXFile(DataTable tbl)
{
ExcelPackage excelPackage = new ExcelPackage();
ExcelWorkSheet excelWorksheet = excelPackage.Workbook.Worksheets.Add("DemoPage");
excelWorksheet.Cells("A1").LoadFromDataTable(tbl, true);
Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
Response.AddHeader("content-disposition", "attachment; filename=ExcelDemo.xlsx");
MemoryStream stream = new MemoryStream(excelPackage.GetAsByteArray());
Response.OutputStream.Write(stream.ToArray(), 0, stream.ToArray().Length);
Response.Flush();
Response.Close();
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…