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/Ma rket/Decry pted/MassE nroll - 2011-03-22- ProvisionFood2.xls
Any idea what might go wrong? Sorry I cannot upload the test file since there are many sensitive information.
Invalid character in the given encoding. Line 1, position 1..
The source Uri:
file:///F:/Clientdata/ACC/Services
Any idea what might go wrong? Sorry I cannot upload the test file since there are many sensitive information.
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
Untitled.png
ASKER
I save the file as XML. It causes error:
Workbook does not have XML Mapping.
Workbook does not have XML Mapping.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
var xmlDoc = new XmlDocument();
xmlDoc.Load(fileName);