Open-XML-SDK
Open-XML-SDK copied to clipboard
Validation of CalcChain considers s attribute of a cell to be a style index
Describe the bug
In the CalcChain part, there is an attribute s of a c (Cell) tag. It's a boolean flag that indicates a child chain. OpenXmlSdk considers it to be an index reference to the styles.xml and if workbook doesn't contain styles, the OpenXmlValidator reports an error.
To Reproduce using var wb = SpreadsheetDocument.Open("workbook_with_child_chain.xlsx", false); var validator = new OpenXmlValidator(); var errors = validator.Validate(wb); Assert.Empty(errors); workbook_with_child_chain.xlsx
Observed behavior There is an error in part '/xl/calcChain.xml' at '/x:calcChain[1]/x:c[3]' with a text
Element 'http://schemas.openxmlformats.org/spreadsheetml/2006/main:xf' referenced by 'c@http://schemas.openxmlformats.org/spreadsheetml/2006/main:s' does not exist in part '/xl/styles.xml'.The index is '1'.
Expected behavior There should be no error, it's a flag.
Desktop (please complete the following information):
- OS: Window 11]
- Office version: Microsoft Office 365, Version 2303 (Build 16227.20280)
- .NET Target: net6
- DocumentFormat.OpenXml Version: 2.20.0
Additional context Workaround: add 2 styles to a workbook.
Hi @jahav,
Per ISO/IEC 29500-1:2016 18.3.1.4 c (Cell) the s attribute on the c (cell element) represents the index of cell element's style. If you have a cell in a spreadsheet that has an s attribute, but no corresponding style and/or missing styles.xml then the error the validator finds is correct.
You can download a copy of the standard here: ISO/IEC 29500-1:2016
@mikeebowen ISO/IEC 29500-1:2016 18.6.1 on the other hand says that s attribute on the c represents:
A Boolean flag indicating whether the cell's formula is on a child chain. True if this cell is part of a child chain, false otherwise. If this is omitted, it is assumed to be the same as the s value of the previous cell.
- the meaning itself is "patched" by MS-OI29500 (different default value), but that's beside the point.
They have same namespace and name, but are in different parts.