简体   繁体   中英

Excel Connection String

I am trying to read Excel, the code I am using runs in one project and is giving error "External table is not in the expected format." for same Excel Input in another project. What may be the issue for code to fail?- My connection string is " strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filePath + ";Extended Properties=\\"Excel 8.0;HDR=" + HDR + ";IMEX=0\\""; "

You need to put single quotes around the Extended properties value.

from here

1. conn = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.15.0;Data Source=C:\Users\Input.xlsx;Extended Properties='Excel 15.0 Xml'");
 2. conn = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.14.0;Data Source="+FilePath+";Extended Properties='Excel 14.0 Xml'");
 3. conn = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Input.xlsx;Extended Properties='Excel 12.0 Xml'");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM