tfussell / xlnt

:bar_chart: Cross-platform user-friendly xlsx library for C++11+
Other
1.49k stars 418 forks source link

`count` attribute on `CT_MergeCells` should be optional #640

Closed luco5826 closed 2 years ago

luco5826 commented 2 years ago

As the title states, the OpenXML schema defines the CT_MergeCells type with the attribute count marked as optional

File OfficeOpenXML-XMLSchema-Strict/sml.xsd

<xsd:complexType name="CT_MergeCells">
    <xsd:sequence>
      <xsd:element name="mergeCell" type="CT_MergeCell" minOccurs="1" maxOccurs="unbounded"/>
    </xsd:sequence>
    <xsd:attribute name="count" type="xsd:unsignedInt" use="optional"/>
</xsd:complexType>

But xlnt uses it as required to check that the count of mergeCells is actually correct, throwing an exception when such attribute is not found:

https://github.com/tfussell/xlnt/blob/master/source/detail/serialization/xlsx_consumer.cpp#L859

The exception:

terminate called after throwing an instance of 'xml::parsing'
  what():  xl/worksheets/sheet5.xml:1:3365: error: attribute 'count' expected
tfussell commented 2 years ago

Thanks for reporting this. I'll fix it soon.

luco5826 commented 2 years ago

I could open a PR for this issue by the end of the month, if it is helpful