C# ClosedXML。将DataTable添加到现有Excel工作表

C# ClosedXML。将DataTable添加到现有Excel工作表,c#,excel,openxml,C#,Excel,Openxml,如何以最快的方式(从性能角度)使用库将DataTable中的值添加到现有的Excel工作表中 注意:可以使用DataTable参数创建新的工作表,但主要问题是在现有工作表中添加值。如果您要处理数百万个单元格,并且希望在消耗最小内存量的同时尽可能快地插入数据,那么这是一种方法 如果希望ClosedXML为您完成工作,请使用: cell.Value = dataTable; or cell.SetValue(dataTable); or cell.InsertData(dataTable); or

如何以最快的方式(从性能角度)使用库将
DataTable
中的值添加到现有的Excel工作表中


注意:可以使用
DataTable
参数创建新的工作表,但主要问题是在现有工作表中添加值。

如果您要处理数百万个单元格,并且希望在消耗最小内存量的同时尽可能快地插入数据,那么这是一种方法

如果希望ClosedXML为您完成工作,请使用:

cell.Value = dataTable; or cell.SetValue(dataTable); or cell.InsertData(dataTable); or cell.InsertTable(dataTable); cell.Value=数据表; 或 cell.SetValue(数据表); 或 cell.InsertData(数据表); 或 cell.InsertTable(dataTable);
请参阅移动到GitHub的

文档中的“插入数据/表格”部分: