NamedStyle.number_format characters are escaped

Issue #1155 on hold
belegnar created an issue

What is the right way to create custom cell formatting?

This code

style1 = NamedStyle(name="date_style", number_format='', font=self.font_data) 
style2 = NamedStyle(name="float_style", number_format=float_format or '# ##0.000', font=self.font_data)

generates in styles.xml following formats, which fails to format cells properly

<numFmt numFmtId="164" formatCode="dd\.mm\.yyyy"/>
<numFmt numFmtId="165" formatCode="#\ ##0.000"/>

Comments (3)

  1. CharlieC

    openpyxl will only escape if it is necessary to create valid XML. The use of backslashes in number formats is something that Microsoft Excel and is not required by the OOXML specification.

  2. Log in to comment