13

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.

Deduplicator
  • 44,692
  • 7
  • 66
  • 118
Benubird
  • 18,551
  • 27
  • 90
  • 141

2 Answers2

36
  • 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

barrowc
  • 10,444
  • 1
  • 40
  • 53
  • 1
    How do you know which attributes are optional? – Spark323 May 24 '18 at 20:21
  • 1
    If you go to page 3912 of the ECMA-376 4th edition part 1 download PDF file and look at line 2301 it says: `` I'll add the page reference into the question and also add references to the 5th edition spec which came out in 2016 – barrowc May 24 '18 at 22:51
  • 1
    On a more general question of finding out which attributes are optional, it's just a question of looking at the XML Schema where attributes will be specified as either `use="required"` or `use="optional"` The Spreadsheet ML schema starts on page 3869 (4th edition) or page 3885 (5th edition) – barrowc May 24 '18 at 23:03
-1

have a look at Open XML SDK. Its a good starting point for what your looking for

Nathan Fisher
  • 7,961
  • 3
  • 47
  • 68