One would be to add a COM reference to Excel and add rows/items/data into the worksheet by going through each column and each row of the dataTable/datagrid and pretty much inserting it into the worksheet. The problem with this is that you dont know how much data there is so it could take a while.
The other may be to use OleDb to connect to the spreadsheet and insert data from the dataTable to the spreadsheet. I will try to see what code I can dig up for this
there are a couple of options, unfortunately for us since its WinForms based, there is apperently an easier way to do it in ASP.NET if we were using ASP.NET
in order to help better, could I ask - how are you populating data into the datagridview Are you entering it manually or have you databound it from a dataset, using a DataAdapter to fill the dataset with records
How export a gridview to excel using c#
JohnWilliams
Goat Spirit
there are a couple of ways.
One would be to add a COM reference to Excel and add rows/items/data into the worksheet by going through each column and each row of the dataTable/datagrid and pretty much inserting it into the worksheet. The problem with this is that you dont know how much data there is so it could take a while.
The other may be to use OleDb to connect to the spreadsheet and insert data from the dataTable to the spreadsheet. I will try to see what code I can dig up for this
Guruprasad H R
cjg6300
there are a couple of options, unfortunately for us since its WinForms based, there is apperently an easier way to do it in ASP.NET if we were using ASP.NET
in order to help better, could I ask - how are you populating data into the datagridview Are you entering it manually or have you databound it from a dataset, using a DataAdapter to fill the dataset with records