Skip to content

feat(ooxml): Add conditional formatting support #136

@arcaputo3

Description

@arcaputo3

Summary

Add support for conditional formatting rules.

Syntax

# Highlight cells > 100
xl -f file.xlsx -s Sheet1 -o out.xlsx cond-format B2:B100 \
  --rule ">100" --bg green --fg white

# Data bars
xl -f file.xlsx -s Sheet1 -o out.xlsx cond-format B2:B100 \
  --rule "data-bars" --color blue

# Color scale (gradient)
xl -f file.xlsx -s Sheet1 -o out.xlsx cond-format B2:B100 \
  --rule "color-scale" --min red --max green

# Icon sets
xl -f file.xlsx -s Sheet1 -o out.xlsx cond-format B2:B100 \
  --rule "icon-set" --icons "3-arrows"

Rule Types

  1. Cell Value: ">100", "<0", "=X"
  2. Data Bars: Visual bars showing relative values
  3. Color Scale: Gradient based on values
  4. Icon Sets: Arrows, traffic lights, etc.
  5. Formulas: Custom formula-based rules

OOXML Implementation

Requires writing <conditionalFormatting> elements to worksheet.xml:

<conditionalFormatting sqref="B2:B100">
  <cfRule type="cellIs" operator="greaterThan" priority="1">
    <formula>100</formula>
    <dxf>
      <fill><patternFill><bgColor rgb="FF00FF00"/></patternFill></fill>
    </dxf>
  </cfRule>
</conditionalFormatting>

Complexity

This is a significant feature requiring:

  • New OOXML writer for conditionalFormatting
  • Differential formatting (dxf) support
  • Multiple rule type handlers
  • Priority management for overlapping rules

Acceptance Criteria

  • Basic cell value rules work
  • Formatting appears correctly in Excel
  • Data bars work (simpler case)
  • Multiple rules on same range work

Priority

Low - Complex OOXML feature

Milestone

v0.8.0+

Related

  • Mentioned in GH#90 (WYSIWYG rendering)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions