Friday, November 27, 2015

Export DataTable to Excel with Open XML in c#

This code sample will illustrate how we can create Excel file from a data table in c#. You will need to add DocumentFormat.OpenXml and WindowsBase dll references to make it work. private static void WriteExcelFile(string outputPath, DataTable table) { using (SpreadsheetDocument document = SpreadsheetDocument.Create(fileToGenerate, SpreadsheetDocumentType.Workbook)) { WorkbookPart workbookPart...