Link to home
Start Free TrialLog in
Avatar of chuang4630
chuang4630

asked on

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.






Avatar of chuang4630
chuang4630

ASKER

The code:

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

Avatar of kaufmed
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
I save the file as XML. It causes error:

Workbook does not have XML Mapping.
ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial