ClosedXML. Adding a DataTable to an Existing Excel Worksheet

How to use the ClosedXML library in the fastest way (in terms of performance) to add values ​​from a DataTable to an existing Excel worksheet?

NOTE. There is a way to create a new worksheet with the DataTable parameter, but the main problem is adding values ​​to the existing worksheet.

+4
source share
1 answer

If you are dealing with millions of cells, and you want to insert data as quickly as possible, consuming the minimum amount of memory, then SAX is the way to go.

If you want ClosedXML to do this job, use:

  cell.Value = dataTable;
 or
 cell.SetValue (dataTable);
 or
 cell.InsertData (dataTable);
 or
 cell.InsertTable (dataTable);

See the Insert Data / Tables section in Documentation.

+6
source

All Articles