Repository navigation
Conversation
Every other colour field turns a 6-digit RGB into ARGB with an FF alpha prefix. Colour scale and data bar colours in conditional rules were written as given, so `"638EC6"` went out as `<color rgb="638EC6"/>`. CT_Color/@rgb is ST_UnsignedIntHex, four bytes, so that value is not schema-valid. Both sites, and the sparkline colour that did the same thing inline, now go through one `toArgb` helper. A 6-digit colour now reads back as its 8-digit ARGB form, because the reader keeps conditional-formatting colours as written. Closes productdevbook#595
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
Closes #595
What was wrong
Every other colour field turns a 6-digit RGB into ARGB with an
FFalpha prefix: fonts, fills, borders, rich text, tab colour and sparklines. Colour scale and data bar colours inconditionalRuleswere written exactly as given:CT_Color/@rgbisST_UnsignedIntHex, anxsd:hexBinaryof length 4 (eight hex digits), so the 6-digit form is not schema-valid.Why the tests didn't catch it
coverage-xlsx-writer.test.tshad a data bar test that wrote"638EC6"and asserted<color rgb="638EC6"/>, so the test pinned the bug. The round-trip tests inconditional-formatting.test.tsall use 8-digit colours.What landed
toArgb(rgb)helper inworksheet-writer.ts.serializeColorAttrsand the colour scale, data bar and sparkline sites all use it. The sparkline site had the same check written inline, and its output is unchanged.serializeConditionalFormattingis shared withwriteXlsxStream/writeXlsxStreamSheets, so the streaming writers are fixed too. There is a test for that.colorScale.colorsanddataBar.colorsay that a 6-digit value is accepted and reads back in 8-digit form. The reader keeps conditional-formatting colours exactly as written, so"638EC6"now reads back as"FF638EC6". It is the same colour, but a strict equality check on a round trip will see the difference. Before this change, the value read back unchanged because the file held the invalid 6-digit form.Tests: two of the three new tests fail against
main, plus the corrected data bar assertion. The third new test checks that 8-digit colours pass through untouched, which already worked.bun run testpasses on Node 24.22.0, with 240 files and 10,701 tests.Checked in Excel
In Excel for Mac, with the colour scale on A1:A10 and the data bars on B1:B10, written by
mainand by this branch. Both files open without a repair prompt. Both show A running red to green and blue bars in B. Excel accepts the six-digit form too, so there is no visible difference in Excel. The change makes the value schema-valid, and the after file shows Excel takes it.Not verified
Summary by CodeRabbit
Enhancements
Documentation