# Advanced Conditional Formatting

**Last Updated:** 2025-11-20

## Overview

Advanced conditional formatting features (color scales, data bars, icon sets) are supported in the template definition schema, but PhpSpreadsheet has limited support for these features. They must be added manually in Excel after template generation.

## Supported Types

### 1. Color Scales (Farbverlauf)

Color scales apply a gradient color based on cell values:

```json
{
  "conditional_formatting": [
    {
      "type": "colorScale",
      "range": "B2:B20",
      "min_color": "#10B981",
      "max_color": "#EF4444"
    }
  ]
}
```

### 2. Data Bars (Datenbalken)

Data bars show visual bars in cells proportional to values:

```json
{
  "conditional_formatting": [
    {
      "type": "dataBar",
      "range": "C2:C20",
      "color": "#4D8EF3"
    }
  ]
}
```

### 3. Icon Sets (Symbolsätze)

Icon sets display icons based on value ranges:

```json
{
  "conditional_formatting": [
    {
      "type": "iconSet",
      "range": "D2:D20",
      "icon_set": "3TrafficLights",
      "show_value": true
    }
  ]
}
```

## Current Implementation

The template generator documents advanced conditional formatting requirements but does not generate them automatically. Notes are added to the Excel file indicating where advanced formatting should be added.

## Manual Addition

After generating an Excel template, advanced conditional formatting can be added manually:

1. Open the generated Excel file
2. Select the range specified in the template definition
3. Home → Conditional Formatting → Choose type
4. Configure colors, thresholds, and options
5. Apply Ordio brand colors

## Basic Conditional Formatting

Basic conditional formatting (cell value conditions, formulas) is fully supported and generated automatically:

```json
{
  "conditional_formatting": [
    {
      "type": "cellValue",
      "range": "E2:E20",
      "operator": "greaterThan",
      "formula": "100",
      "style": {
        "fill": { "color": "#10B981" },
        "font": { "color": "#FFFFFF", "bold": true }
      }
    }
  ]
}
```

## Ordio Brand Colors for Conditional Formatting

- **Success/High:** #10B981 (Ordio Success Green)
- **Warning/Medium:** #F59E0B (Ordio Warning Orange)
- **Error/Low:** #EF4444 (Ordio Error Red)
- **Primary:** #4D8EF3 (Ordio Blue)
- **Neutral:** #6B7280 (Ordio Text Secondary)

## Best Practices

1. **Use Basic Formatting When Possible:** Basic conditional formatting is automatically generated
2. **Document Advanced Formatting:** Include notes in templates for manual addition
3. **Consistent Colors:** Use Ordio brand colors for consistency
4. **Clear Thresholds:** Define clear value thresholds for color scales and icon sets
5. **Test in Excel:** Verify conditional formatting works correctly after manual addition

## Limitations

- Advanced conditional formatting requires manual addition
- Color scales, data bars, and icon sets not automatically generated
- Complex icon set configurations require Excel expertise
- Dynamic updates require manual refresh

## Future Enhancement

If PhpSpreadsheet adds support for advanced conditional formatting or a compatible extension becomes available, generation can be automated.
