Skip to content

xlsx: read conditional formats kept only in the x14 extension list - #2262

Open
pick2510 wants to merge 1 commit into
storytold:mainfrom
pick2510:fix/x14-conditional-formats
Open

pick2510 wants to merge 1 commit into
storytold:mainfrom
pick2510:fix/x14-conditional-formats

Conversation

@pick2510

@pick2510 pick2510 commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Excel 2010+ writes a conditional format into the extension list alone when the rule's formula refers to another sheet: x14:conditionalFormatting, with formulas in xm:f and the format inline in x14:dxf. Some exporters write every rule that way. GridCraft read that list only for data-bar extensions and dropped these rules. In three grade sheets from a private corpus (not committed), the pink "repeat student" highlighting over a whole block of rows was missing.

  • cf_rule(): the cfRule type match is now shared between <conditionalFormatting> and the x14 list.
  • styles::read_dxf(): dxf parsing is shared, and also reads an inline x14:dxf.
  • A standalone x14 rule (any formula or text type; data bars and icon sets still go through the existing extension path) is read with its xm:sqref ranges, priority and stop-if-true. It is saved as an ordinary conditional format. A rule without a range is skipped with the existing warning.

Tests (built in code)

crates/xlsx/src/tests/x14_cond_formats.rs:

  • x14_only_rules_are_read: a cell-value rule (operator, formula, font and fill colours, priority) and an expression rule over two ranges are read, and a rule without a range is dropped.
  • x14_only_rules_survive_saving: the same checks after write_xlsx and a re-read.

Both fail on main, where no rules are read.

CI

cargo xtask ci: fmt, clippy, assets, layers, wasm, parity and keytips pass, and every test passes except the pre-existing header_autofit::table_filter_autofit_works_through_command_and_header_double_click. That test fails identically on main on this machine with Carlito installed (see #2257).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • XLSX workbooks now retain more conditional-formatting rules stored in Excel 2010 extensions, including cell-value and formula-based rules.
    • These rules preserve their applicable ranges, formulas, priorities, operators, and formatting when the workbook is read and saved.
    • Unsupported or incomplete extension rules may still be skipped.

Excel 2010+ writes a conditional format into the extension list alone
(x14:conditionalFormatting, formulas in xm:f, the format inline in
x14:dxf) when its formula refers to another sheet, and some exporters
write every rule that way. GridCraft read that list only for data-bar
extensions and dropped these rules, so such sheets lost their
highlighting.

The cfRule parsing is shared (cf_rule), the dxf parsing too (read_dxf);
a standalone x14 rule is read with its xm:sqref ranges and saved as an
ordinary conditional format.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Walkthrough

The XLSX reader now reads supported conditional-format rules stored only in Excel 2010 extensions. It parses inline differential formats and includes tests for reading and round-tripping these rules.

Changes: X14 conditional formats

Layer / File(s) Summary
Reusable differential-format parsing
crates/xlsx/src/styles.rs
The new public read_dxf function parses differential formats. read_styles now uses this function for each <dxf>.
X14 rule ingestion
crates/xlsx/src/sheet_read.rs, crates/xlsx/src/tests/*, docs/file-format-parity.md
The worksheet reader parses supported standalone rules from Excel 2010 extensions, including their ranges, formulas, and inline styles. Tests check parsed rule properties and save-and-reread behavior. The parity metadata documents the change.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant X14Extension
  participant read_cf
  participant cf_rule
  participant read_dxf
  participant Worksheet
  X14Extension->>read_cf: supplies extension conditional-format rules
  read_cf->>cf_rule: parses rule attributes
  cf_rule-->>read_cf: returns a rule or None
  read_cf->>read_dxf: parses inline differential format
  read_cf->>Worksheet: adds valid rule with ranges
Loading

Suggested reviewers: echelon, marekspodbiedry

Merge Risk: Minimal · up to 13923

The color-scale concern does not block this change; no other merge-blocking issue is established.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: reading conditional formats stored only in the Excel 2010+ x14 extension list.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Finishing Touches

🧪 Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.
ℹ️ Recent review info

⚙️ Run configuration

📥 Commits

Reviewing files that changed from the base of the PR and between a1c8454 and 1392304.

📒 Files selected for processing: 5

  • crates/xlsx/src/sheet_read.rs
  • crates/xlsx/src/styles.rs
  • crates/xlsx/src/tests/mod.rs
  • crates/xlsx/src/tests/x14_cond_formats.rs
  • docs/file-format-parity.md

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.

@FredApps FredApps left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ReviewerA — source-read COMMENT (not an approval)

I read the head of the diff: the xlsx reader reads conditional formats kept only in the x14 extension list. Excel 2010 and later store some rules (data bars with extra options, icon sets with custom icons, rules referring to other sheets) in extLst under the x14 namespace, and a reader that looks only at conditionalFormatting loses them. The rule construction (cellIs, expression, containsText and others) is moved so both places share it, and read_dxf is imported for the differential formats. Losing rules on open is a data-loss bug, so reading the extension is right. The parser handles untrusted XML: bounds on the number of rules and on formula length apply to the new path too, and a round-trip test with a file from Excel that has an x14-only rule is the proof. I read the imports and the removed block. I have not run it, and no exact-head CI result exists for this head. Nothing was run.

I ran nothing and have no exact-head CI result for this PR, so this is not an approval. Where a diff was long I read its code hunks rather than every generated or documentation line.

Status: waiting_author.

@pick2510

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Action not completed

Already reviewed the last commit. Use @coderabbitai full review to rerun a review of the entire changeset.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants