简体   繁体   中英

Problems Reading a .xlsx file?

I made a test file, and ran through the excel file just fine, but whe nI insert one with a lot of data, I get the following error:

The Microsoft Office Access database engine could not find the object 'Sheet1$'

Which seems incredibly obvious, but 'Sheet1' is surely there, just like in my test file - I have checked about 30 times. There is only data on the first Sheet and it is clearly named 'Sheet1' like the default. Any idea why I would still be getting this error?

code:

string path = Server.MapPath("~") + "\\attachments\\ejmaps\\ejmaps.xlsx";
string connString = string.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties=\"Excel 12.0 Xml;HDR=YES\";");
OleDbDataAdapter adapter = new OleDbDataAdapter("SELECT * FROM [Sheet1$]", connString);   

odd... I had changed the name back to what it was originally (EJMaps Pull.xlsx) and it worked?

Any ideas why that would be?

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