Repository navigation
XLSX: write one cfvo per icon in icon-set rules (#235) - #262
Merged
h-a-n-a-s-h-i merged 2 commits intoOct 11, 2026
Merged
Conversation
An icon-set rule without stored thresholds (every rule made by home.conditionalFormat, and the sales sample) was written as an empty <iconSet>, which CT_IconSet forbids (cfvo minOccurs 2); openpyxl drops it. The writer now always emits one cfvo per icon: the stored thresholds when there is one per icon, the lower bound prepended when it is missing, else Excel's defaults (percent 0/33/67, 0/25/50/75, 0/20/40/60/80). Evaluation read the thresholds as one fewer than the icons, but files carry one per icon (the first is the lower bound), so thresholds read from a file were ignored. Both now share icon_count and default_icon_thresholds in gridcraft-model; icon_count is clamped to 3..=5 so a set name like "0Foo" can't underflow k - 1. generated with Claude Code
generated with Claude Code
Member
|
Merged — thank you for the contribution! (I resolved a small conflict in contributors/people.toml while merging.) If you haven't already, come join us on the ArtCraft Discord: https://discord.gg/artcraft |
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.
Fixes #235.
Problem
An icon-set rule without stored thresholds was written as
<iconSet iconSet="3Arrows"></iconSet>.CT_IconSetrequires at least twocfvochildren, and openpyxl discards the rule. Every rule created byhome.conditionalFormathas no thresholds, so the built-insalessample is affected too.While looking at the reader I found a second, related bug. Files carry one
cfvoper icon (the first is the lower bound, as in the existing round-trip test), but evaluation only used stored thresholds when there was one fewer than the icon count. Custom thresholds read from a file were therefore ignored and the defaults applied.Change
gridcraft-model: newicon_count(moved fromengine::cf, now re-exported there) anddefault_icon_thresholds, so writer and evaluation share the same defaults: percent0/33/67,0/25/50/75,0/20/40/60/80.cfvoper icon. It writes the stored thresholds when there is one per icon, prepends the lower bound when that is the only one missing, and falls back to the defaults otherwise.icon_countis clamped to 3..=5. Previously a set name like0Foofrom a file gavek = 0, andk - 1underflowed.Behaviour change: rules without thresholds were previously evaluated by percentile. They now use percent of the min..max span, which is what the written file says. My understanding is that Percent 33/67 is Excel's default for a new icon-set rule (the ECMA-376 example shows the same values). I did not verify that against a running Excel.
Tests
xlsx::tests::roundtrip::icon_sets_always_write_one_cfvo_per_icon: empty thresholds, missing lower bound and an unknown set name, plus a read-back check.engine::tests::icon_set_thresholds_from_files_pick_the_icon: default thresholds, and file-style thresholds (one per icon) deciding the icon.cargo xtask cion Windows: fmt, clippy, test, assets, layers and wasm pass.parityreportsdocs/parity-checklist.mdas out of date, but regenerating it gives no content diff (LF vs CRLF on a Windows checkout), so it is unrelated to this change.Also adds my own entry to
contributors/people.toml(real name), asdocs/contributors.mdasks, committed by me in this PR.(made with Claude Code)
🤖 Generated with Claude Code