PowerPoint2007 Writer : Honour the format code of an axis - #903
Open
dkulyk wants to merge 2 commits into
Open
Conversation
dkulyk
force-pushed
the
fix/chart-axis-format-code
branch
from
August 22, 2026 10:27
a617c81 to
0f45264
Compare
`writeAxis()` wrote `sourceLinked="1"` right next to the `formatCode` it had just written, and that attribute tells the renderer to take the number format from the source data instead. The format code was therefore visible in the file and discarded by PowerPoint, which is why `Axis::setFormatCode()` reads as having no effect at all. The library already knows the right value: the three data-label sites in the same file (`getDlblNumFormat()`) all write `sourceLinked="0"`. Only the axis was out of line, hardcoded to `'1'` since b957fb9 (2016-03-02, the Gridlines implementation). Link the format only when no format code was asked for, so that a default axis keeps inheriting the format of its data and nothing changes for a deck that never called the setter. Fixes PHPOffice#632
dkulyk
force-pushed
the
fix/chart-axis-format-code
branch
from
August 23, 2026 12:10
0f45264 to
5f3ead7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
writeAxis()writes the axis' format code and then immediately tells the renderer to ignore it:sourceLinked="1"means "the number format comes from the source data", so theformatCodesitting next to it is discarded by PowerPoint. The attribute is in the file, which is why the issue reads as "it still doesn't work" rather than "nothing is written".Why
'0'is the right value. The library already writes it correctly everywhere else — in the same file, all three data-label sites usesourceLinked="0":sourceLinkedgetDlblNumFormat())000getFormatCode())1The axis is the only one out of line. It has been hardcoded to
'1'since b957fb9 (2016-03-02, the Gridlines implementation) and was never revisited.The fix is not an unconditional
'0'— that would take the inherited format away from every deck that never called the setter.Axis::DEFAULT_FORMAT_CODEis'general', so:Fixes #632
Possibly related, deliberately not claimed here. #610 and #420 report chart series data not being formatted as numbers. They may share this cause, but I have not measured them.
The ODPresentation writer never reads
getFormatCode()at all. ODF expresses a number format as a<number:number-style>element referenced throughstyle:data-style-name, not as an attribute, and there is no such machinery in that writer today — that is separate work, not a matter of copying this line across. Hence theAvailable only on the PowerPoint2007 Writernote in the documentation, matching the existing one on Crossing.Checklist:
Axis::setFormatCode()had no writer-side coverage at all —AxisTestonly exercises the getter/setter, andnumFmtappeared nowhere in the writer tests.PptChartsTest::testAxisFormatCodenow covers both branches (default and explicit format code) and validates each against the ECMA-376 schema.setFormatCodewas not mentioned anywhere indocs/. Added a Number format section todocs/usage/shapes/chart.md, next to Bounds and Crossing.