joshmcode
joshmcode

Reputation: 3642

Empty Excel Shows a Number Value when Viewing XML. Causes XMLReader to not working Correctly

I wrote an Excel parser in .NET/C#. It utilizes the XMLReader class in System.XML and works great. But I have a strange bug where an empty cell comes through as the string "1074." If you look at the Excel file in the GUI the cell is empty. But if you unzip the file, it shows the following for that same cell.

<c r="Y311" s="1" t="s"><v>1074</v></c>

This issue is repeated over and over again under the following circumstances:

Because the XML says there is a value there, when the XMLReader gets to that part of the spreadsheet, it parses the value as "1074" instead of as an empty cell.

Additionally, prior to Y311, all empty cells have the following XML form (which is correct of course):

<c r="Y300" s="1"/>

And then no <v></v> attribute after that, because the cell is empty. This is how all empty cells should appear.

Any idea why some of these cells are populating with "1074" even though they should be empty?

Upvotes: 0

Views: 332

Answers (1)

barrowc
barrowc

Reputation: 10679

The type of the cell is SharedString - t="s" - which means that the value - <v>1074</v> - is a reference into the shared strings table rather than representing the value shown in the cell

If you look at sharedstrings.xml in the xl folder of the .xlsx file, you will find the relevant string

Details on the various cell types are in this answer

Upvotes: 1

Related Questions