Skip to content

XLSX: icon set assigns wrong bands (cfvo thresholds dropped and type ignored) #406

Description

@developer0hye

Summary

Icon-set conditional formatting assigns the wrong band to most cells: values land one band too low. In 10_kpi_tracker_en.xlsx the 3Arrows rule uses type="num" thresholds [0, 0.9, 1.0] (≥1.0 → green up, [0.9,1.0) → yellow side, <0.9 → red down), but office2pdf renders 107% (1.07) with the middle/yellow icon and 93% (0.93) with the low/red icon — one band below Excel.

Two root causes in the icon-set threshold path:

  1. umya-spreadsheet drops the cfvo children. The <cfvo> elements are written as start/end tag pairs (<cfvo type="num" val="0.9"></cfvo>, openpyxl style); umya's IconSet reader only matches Event::Empty, so get_cfvo_collection() comes back empty (the same reader gap fixed for DataBar in fix: read dataBar cfvo and color children written as start/end tags MathNya/umya-spreadsheet#347). office2pdf then falls back to equal-thirds thresholds, which do not match the rule.
  2. office2pdf ignores the cfvo type. apply_icon_set_rule computes every threshold as min_val + range * (val / 100), treating the value as a percentage. For type="num" the value is absolute (0.9 means 0.9), for type="percentile" it is a percentile — so even with the cfvos populated the thresholds would be wrong.

Reproduction

Convert an XLSX whose iconSet rule uses type="num" cfvos written as start/end tags and compare the per-cell icon band with an Excel PDF export.

Expected

Each cell's icon matches Excel's band for the rule thresholds (num/percent/percentile honored).

Actual

Bands fall back to equal-thirds and ignore the cfvo type, so most cells show an icon one band too low.

Fix direction

Parse the iconSet cfvo type+val list from the raw worksheet XML (office2pdf already extracts iconSet type there), and compute thresholds per cfvo type (num = literal, percent = min+range·val/100, percentile = percentile of the range, min/max = extremes). This bypasses the umya reader gap without a dependency bump.

Related

Related: #377, #367, #371

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions