Question of Load xls to XmlDoc

I try to load the .xls (NOT .xlsx) to XML but failed every time. This existing code has been in production for long time so I do not think it is the problem. The error message:

Invalid character in the given encoding. Line 1, position 1..

The source Uri:
file:///F:/Clientdata/ACC/Services/Transport/Ftp/In/Market/Decrypted/MassEnroll - 2011-03-22- ProvisionFood2.xls

Any idea what might go wrong? Sorry I cannot  upload the test file since there are many sensitive information.






LVL 1
chuang4630Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

chuang4630Author Commented:
The code:

                var xmlDoc = new XmlDocument();
                xmlDoc.Load(fileName);

0
käµfm³d 👽Commented:
An ".xls" file is not XML--it is a binary file that represents an Excel workbook. A ".xlsx" file is just the newer 2007+ format for Excel files. They are also binary files. In order to load the data into an XmlDocument class, you would need to save the file into XML format. For example, Excel 2003 provides you with this option:
Untitled.png
0
chuang4630Author Commented:
I save the file as XML. It causes error:

Workbook does not have XML Mapping.
0
käµfm³d 👽Commented:
I think I highlighted the wrong option. Try using the "XML Spreadsheet" option.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
XML

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.