我目前正在使用EPPlus填充工作表,如下所示:
List<dynamic> myData = ...
int col = 1;
int row = 1;
foreach (var data in myData)
{
worksheet.Cells[row, col++].Value = data.field1;
worksheet.Cells[row, col++].Value = data.field2;
worksheet.Cells[row, col++].Value = data.field3;
worksheet.Cells[row, col++].Value = data.field4;
worksheet.Cells[row, col].Style.Numberformat.Format = "yyyy-MM-dd";
worksheet.Cells[row, col++].Formula = "=DATE(" + data.field5.ToString("yyyy,MM,dd") + ")";
worksheet.Cells[row, col++].Value = data.field6;
worksheet.Cells[row, col++].Value = data.field7;
worksheet.Cells[row, col++].Value = data.field8;
row++;
}
但是有2万行时,速度却没有我想要的快。
问题:对LoadFromCollection
做同样的事情应该更快?
worksheet.Cells["..."].LoadFromCollection(...)