Paper Office
paper-xlsxAPI referencepreserve.styletrans

openpyxl.preserve.styletrans

paper-xlsx 0.2.1 API reference

Translate the model's style indices into the ORIGINAL file's xf indices.

The model's style numbering drifts from the file's at load time: _normalise_numbers (styles/stylesheet.py:95,165-190) rewrites custom numFmtIds in place, and apply_stylesheet may append arrays the file never had (e.g. the Normal named-style bootstrap). Emitting model indices into a spliced sheet therefore corrupts styles on any non-openpyxl producer — measured on the LibreOffice-authored fixtures.

The translator parses the ORIGINAL styles.xml through upstream's own Stylesheet machinery, giving arrays that are positionally aligned with the file's cellXfs but expressed in model semantics — directly comparable to the model's arrays. Cells whose style exists in the file reuse its index; anything else becomes an appended xf (never a rewrite of an existing entry), with custom number formats re-translated into the FILE's numFmt numbering.