How to update excel file using datagrid in c#/asp.net

  • Thread starter Thread starter vinay
  • Start date Start date
V

vinay

I have read the excel file into the datagrid and modified some data.
Now i want to update the excel file with the data. How do I do it.
Please help me.
 
Vinay,

If you have used an OleDb provider to get the data, (through
OleDbDataAdapter), then you should be able to create OleDbCommand objects
for the update, insert, and delete operations. Once you have those, connect
them to the data adapter and then pass the data set from the grid back to
the data adapter through the Update method. It should then update your
Excel sheet.

If you populated the grid manually, then you will have to open Excel
through Automation, and then update the values that have changed in the
grid. You can make this easier by calling the GetChanges method on the
DataSet, to get the changes that have occured.

Hope this helps.
 
Back
Top