Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Exporting excel charts with form controls (spinner) to Powerpoint Mike B Charts and Charting in Excel 1 November 18th 07 04:10 PM
Embedding Excel in a C# WinForm NickHK Excel Programming 1 January 8th 07 06:53 AM
excel in winform NickHK Excel Programming 0 December 4th 06 04:05 AM
Exporting Data from Excel Form to HTML Page Lenap Excel Programming 1 August 2nd 06 02:25 PM
exporting data from a form to a spread sheet R.H.[_2_] Excel Programming 3 June 4th 04 12:51 PM


All times are GMT +1. The time now is 07:49 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"