What do excel xml cell attribute values mean?

Benubird picture Benubird · Aug 20, 2013 · Viewed 12.1k times · Source

Looking at the xml of an excel spreadsheet, I see these cells under sheetData/row:

<c r="T1" s="23" t="s"><v>17</v></c>
<c r="AP1" s="98"><v>28</v></c>

By looking at the spreadsheet, I can see that the first cell is a string (which I can look up in the sharedStrings file), and I know that the second one is the value "28", from which I hypothesise that if a cell has the attribute t="s", it is a string, otherwise it is a value. Is this correct?

I am guessing that the r, s, and t stand for 'row', 'style', and 'type', but can someone clarify for me what they mean and what the possible values for them are? E.g, I see some cells with the attribute t="str", is that the same as "s" or does it mean something special?

I couldn't find any documentation or specification for the excel xml files, so if such a thing exists it would be helpful to be pointed in it's direction.

Answer

barrowc picture barrowc · Aug 21, 2013
  • r = Reference
  • s = Style Index
  • t = Cell Data Type

The documentation for the Cell class is here

The possible cell data types are:

  • b - boolean
  • d - date in ISO8601 format
  • e - error
  • inlineStr - string that doesn't use the shared string table
  • n - number
  • s - shared string
  • str - formula string

These values are in section 18.18.11 of the ECMA-376 standard which can be found here (specifically they are on pages 2442-2443 of the PDF file in the ECMA-376 4th edition part 1 download)

Looking at the XML schema later in that PDF file (page 3912, line 2301), the use of the t attribute is optional and the default value is n - i.e. a number


Part 1 of the 5th edition of the ECMA-476 spec was released in 2016. The equivalent page references for the 5th edition are: page 2451 for the documentation of ST_CellType and page 3928, line 2301 for the ST_CellType entry in the XML schema