Click here to Skip to main content
15,921,905 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I am downloading some .xls files from ftp server and those .xls files are system generated excel files through code. I am trying to convert that excel file into data table as for db insertion... but when i am trying to read the file .....
I am getting following error while i am trying to upload system generated excel file.

"External table is not in the expected format."

One more thing is that i am unable to convert that .xls to datatable but i have tried to open the excel file manually and re saved the file... after the saving the file works properly .... As this is automation process i want to convert the files direclt in my project pls pls help me out yar

Please help me out....

Thanks in advance
Posted

The first thing to do is find out why it works afterwards.
take one of the "non-working" versions, and copy it. Then "open the excel file manually and re saved the file" as you did before under a new name.

Now use a hex editor (or binary comparison tool) to examine the two fines and work out what the difference is. Once you know that, you can either adjust the tool generating the files, or write a pre-processor which takes the "faulty" version and "upgrades" it before passing it to the XSL processor.

But until you know what the difference is, nobody else can help you!
 
Share this answer
 
Comments
[no name] 23-Aug-13 8:46am    
My vote 5 to this solution
jing567 23-Aug-13 8:50am    
Hello OriginalGriff,
This is error where every one is facing while reading a system generated excel file.... but no one gave the correct solution when i googled...
OriginalGriff 23-Aug-13 8:55am    
Depends on what generated the file, and what you did to the file to make it "readable".

Since you have both "unreadable" and "readable" versions, you can work out what the difference is...no one else can do that for you, because we don't have the data.
jing567 23-Aug-13 9:02am    
It is in readable and more ever i have given complete rights to read and write the file.... sorry to say that u are not getting into my point... u are going it in another way... which i am not expecting for...
OriginalGriff 23-Aug-13 9:13am    
You have a system which generates an unreadable file - call it "badfile.xls"
You have some software which can read it and write it as a new file - call it "goodfile.xls"
I do not know what either of these pieces of software are, but you refer to them in your original question.

Until you know what the differences between "badfile.xls" and "goodfile.xls" are, we cannot help you to modify your code to read "badfile.xls".

This is not an access or permissions problem: it is a data format problem, so you need to look at the data in the two files and work out what the difference between them is.
can you put your oledbconnection if something like this


C#
OleDbConnection oconn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filepath + ";	Extended Properties=Excel 8.0");


if yes there you should save it as 2003 and in .xls format it may work for you


thanks....:)
 
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