Click here to Skip to main content
15,892,674 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to connect to different excel sheet with different versions such as (2007 and 2010) in c# win. form?
Posted
Updated 7-Feb-14 22:16pm
v3
Comments
Richard MacCutchan 8-Feb-14 4:38am    
AFAIK both 2007 and 2010 use the ACE driver.

1 solution

Goes like...

C#
/* on top */
using System.Data.OleDb;


....

string filePath = @"C:\MyExcel.xlsx";
string connectionstring = "provider=Microsoft.ACE.OLEDB.12.0;data source={0};extended properties='Excel 12.0;HDR=YES;'";
connectionstring = connectionstring.Replace("{0}", filePath ); 

OleDbConnection oConn = new OleDbConnection(connectionstring);
oConn.Open();
...
oConn.Close();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900