Click here to Skip to main content
15,889,838 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i importing data from excel using c#. but when i try 20.000 rows import from excel i getting this error:
External table is not in the expected format.


when i try to import 5000 rows, there is no error.

bytheway on my local computer i can import 20.000 rows but when i run the import page on the server, i getting error.

what do you think about this problem?

What I have tried:

my excel connection string is
OleDbConnection _con = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + ExcelFileName + ";Extended Properties=Excel 12.0 Xml;");
Posted
Updated 6-Feb-17 22:28pm

Most often when I come across this type of problem it's because some of the data is of the wrong type. Unfortunately, Excel lets you mix types in columns and when a bad type is hit the import can bomb.

Unfortunately, you didn't send an actual error message for us to analyze. This is always helpful as it usually points to the the real problem. I can only guess from experience.

One place to check: what is the difference between your local machine and the server? Apparently, if there are type errors the local machine is willing to swallow them.

 
Share this answer
 
this connection string solved my problem. I added IMEX=1 attribute.

OleDbConnection _con = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + ExcelFileName + ";Extended Properties=\"Excel 12.0 Xml;HDR=YES;IMEX=1\";");
 
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