I want to export a data table to an Excel file with EPPlus. That data table has a property with int type, so I want the same format in the Excel file.
Does anyone know way to export a DataTable like this to Excel?
using (ExcelPackage pck = new ExcelPackage(newFile)) { ExcelWorksheet ws = pck.Workbook.Worksheets.Add("Accounts"); ws.Cells["A1"].LoadFromDataTable(dataTable, true); pck.Save(); }
That should do the trick for you. If your fields are defined as int EPPlus will properly cast the columns into a number or float.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With