![]() |
Winform Exporting Data to Excel form Datagridview
How can i optimize the perfomance of exporting data from datagridview with
500 rows of data to excel? I've added reference to Microsoft Excel 11.0 object library. It's taking 3-4 minutes to export 500 rows. below is the code, which i wrote: Excel.ApplicationClass excelApp = new Excel.ApplicationClass(); int ColumnIndex = 0; foreach (DataGridViewColumn col in dgv.Columns) { ColumnIndex++; excelApp.Cells[1, ColumnIndex] = col.HeaderText; } int rowIndex = 0; foreach (DataGridViewRow row in dgv.Rows) { rowIndex++; //ColumnIndex = 0; for (int colIndex = 1; colIndex < dgv.Columns.Count; colIndex++)// (DataGridViewColumn genCol in dgv.Columns) { //ColumnIndex++; excelApp.Cells[rowIndex + 1, colIndex] = row.Cells[colIndex].Value; } } Would appriciate any good suggetions or help |
All times are GMT +1. The time now is 05:39 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com