Click here to Skip to main content
15,891,513 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am reading a excel file using Excel object and Oledb SqlDataAdapter.
When the sheet name contains special char like .(dot),-(hyphen )it's throwing the following error.

C#
The Microsoft Access database engine could not find the object ''July - File$'A2:F1048576'. Make sure the object exists and that you spell its name and the path name correctly. If ''July- File$'A2:F1048576' is not a local object, check your network connection or contact the server administrator.
Posted
Comments
Prasad Avunoori 11-Mar-15 7:13am    
If i remove the .(dot) in the sheet name and import then it's working fine.
Maciej Los 11-Mar-15 16:08pm    
Post your code. I think there is a typo ;)

1 solution

I would recommend to not use OleDb for reading Excel. It's one of Microsofts stepchildren in .Net. The error you're describing there is typical. Take a look at these alternatives (some only allow for writing Excel files, I had this list already compiled and leave it as it is):

A free "Export to Excel" C# class, using OpenXML[^]
ExcelExportLib[^]
EPPlus[^]
excellibrary[^]
NPOI
[^]
ExcelPackage[^]
ExML[^]
Read and Write Excel Files Content without Excel Automation using NPOI[^]
SmartXLS[^]
OpenXML[^]
Open XML SDK 2.0 for Microsoft Office[^]

edit: typo
 
Share this answer
 
v2
Comments
Prasad Avunoori 11-Mar-15 8:06am    
Thanks, Manchanx
[no name] 11-Mar-15 8:23am    
You're welcome.
Maciej Los 11-Mar-15 16:13pm    
Disagree ;( OleDb for MS Excel is quite good, but it depends on... many factors - of course. Please, read my comment to the question. Dot in sheet name is not a problem. I believe there is a something wrong in connection string or sql command.
[no name] 11-Mar-15 16:31pm    
No worries, Maciej :) You probably have more experience with it than me then. I'll ask you if I should ever need to use it for whatever reason and run into a problem ;)
- Sebastian
Maciej Los 12-Mar-15 16:56pm    
As i mentioned in my comment, the usage of Oledb depends on many factors. If the data in MS Excel are stored in tabular form (with headers) it is much, much faster to load these data via Oledb than via any other interface. Try to load data cell by cell and via Oledb. Guess which method will be faster...

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