Vote count: 0
I am using the Microsoft Office Interop to iterate a DataTable and write the data to Excel. This is the bottleneck in my application, everything up to this point takes roughly 90 seconds to complete however when it comes to writing to Excel the process takes 3 minutes! What is the proper way of writing a DataTable to Excel? I am utilizing VS2015 and Excel 2013
This is the process that I have that is dreadfully slow (it writes 5 columns, and 1200 rows. Can this be sped up? Is there a better process?
public static void WriteDataTableToExcel(DataTable dtName)
{
int i = 0;
int j = 0;
for (i = 0; i < dt.Columns.Count; i++)
xlWorkSheet.Cells[1, i + 1] = dt.Columns[i].ColumnName;
for (i = 0; i < dt.Rows.Count; i++)
for (j = 0; j < dt.Columns.Count; j++)
xlWorkSheet.Cells[i + 2, j + 1] = dt.Rows[i][j];
}
asked 10 secs ago
Export Data From DataTable To Excel
Aucun commentaire:
Enregistrer un commentaire