Quantcast
Channel: EPPlus Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 2262

Commented Unassigned: XmlException on loading some xlsx files. [14948]

$
0
0
If we load xlsx file created by some accounting software, access to Workbook.Worksheets lead to XmlException: Unexpected XML declaration. The XML declaration must be the first node in the document, and no white space characters are allowed to appear before it. Line 49, position 16.

One reason is that xml files created by this applications are formatted (with tabs and newlines).
In Worksheet.cs we have set of Load functions (LoadCells(xr);, etc.) whict are not expecting any whitespace.
For example, in LoadColumns we have following peace of code:
```
if (ReadUntil(xr, "cols", "sheetData"))
{
while(xr.Read())
{
if (xr.LocalName != "col") break;
if (xr.NodeType == XmlNodeType.Element)
```

This will not work if we have whitespace between "cols" and "col" nodes.
Possible solution is to skip all whitespace like this
```
while(xr.Read())
{
//skip whitespace
while (xr.NodeType == XmlNodeType.Whitespace) { xr.Read(); }
if (xr.LocalName != "col") break;
```





Comments: Fixed in changeset b8a1a7092366

Viewing all articles
Browse latest Browse all 2262

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>