Hi, I have the excel sheet , I want to keep it as datasource to the gridview . gridview will be editable so whatever the data updated sholud be write to again in excel sheet with respected location in sheet. How can i do this ? Please help me .
A:
You could use the Jet driver to select from the spreadsheet via OLEDB. Your spreadsheet will need to be laid out in a table-like fashion, and you can have some painful problems with type guessing, but this may work for your situation.
Connection string samples here
Sam
2010-02-16 05:30:56
Great ... Now i can load the data to gridview but now i want to write data whatever updated in grid to back Excel sheet . what should i hav e to do? I am using c# _ Asp.net 3.5 combination
Lalit
2010-02-16 06:33:37
It's been a long time since I used WebForms, but I imagine there's an UpdateCommand property on the GridView DataSource? You should be able to craft a query along the lines of "UPDATE [Sheet1$] SET Column1 = ?, Column2 = ? WHERE Column3 = ?" and map the parameters to gridview columns.
Sam
2010-02-16 08:14:17
I should add - it's not usually a great idea to manipulate an Excel spreadsheet via a website, as Excel is inherently single-user and you'll run into problems if you have multiple web users attempting to access the same spreadsheet.
Sam
2010-02-16 08:18:02
oh! Thanks for reply and suggestion Sam, Actually this application is for Admin of system who is single user.So i think i can avoid multiple access for same file. isn't it?
Lalit
2010-02-16 09:08:14