Reputation:
How do I display, edit and save an Excel sheet data in sql server?
Any help would be appreciated.
Upvotes: 0
Views: 107
Reputation: 7907
You can use this connection string for excel 2003:
con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +
filePath + ";Extended Properties=Excel 8.0");
and for Excel 2007, you can use this connection string:
con = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" +
filePath + ";Excel 12.0;HDR=YES");
After if you can execute direct query for excel sheet. You can also take the reference of "Microsoft.Office.Interop.Excel.dll" DLL and use it.
Upvotes: 1
Reputation: 21695
You can use the Microsoft.ACE.OLEDB provider to connect to an Excel sheet using an OLEDB connection. You can then query the Excel sheet directly like you would do a database.
Upvotes: 1