leonardo-m
2/20/2020 - 9:05 PM

create xlsx from dataTable with EPPLUS

 var FilePath = HttpContext.Current.Server.MapPath("~/TempFile/tempReport.xlsx");
            System.Data.DataTable Dt_Issues = ExportToExcel(pData);

            ExcelPackage pack = new ExcelPackage();
            
            ExcelWorksheet worksheetop = pack.Workbook.Worksheets.Add("Sheet 1");
            worksheetop.Cells["A1"].LoadFromDataTable(Dt_Issues, true);
            FileStream objFileStrm = File.Create(FilePath);
            objFileStrm.Close();

            File.WriteAllBytes(FilePath, pack.GetAsByteArray());
            //Close Excel package 
            pack.Dispose();