Reputation: 1943
My excel generation time is quite long.So i refer this for time reduction:
How to speed up dumping a DataTable into an Excel worksheet?
But, I'm not able to get what are these two variable:
string [] columnNames, string [] fieldNames in the following method.
private void RenderDataTableOnXlSheet(DataTable dt, Excel.Worksheet xlWk, string [] columnNames, string [] fieldNames)
{}
I have only Datatable and worksheet. How can I generate colomnNames and FieldNames as a string[] from this?
Upvotes: 1
Views: 109
Reputation: 174309
fieldNames:
var fieldNames = dt.Columns.Cast<DataColumn>()
.Select(x => x.ColumnName).ToArray();
columnNames: As far as I understand, that should be the same in the default case.
The reason for two different parameters seems to be that you might want to change the printed name of the column in the Excel file.
Upvotes: 1