A workbook applies a <patternFill> to cell A1 using each of the 16 ST_PatternType values that carry foreground/background colours, paired with five colour families.
Library verdicts: python-xlsx: — xlsxjs: pass
| Feature id | xlsx/cell-fill-pattern--blue-yellow--light-grid |
|---|---|
| Format | xlsx |
| Category | cell-formatting |
| Family | xlsx/cell-fill-pattern |
| Axis values | color=blue-yellow, pattern=light-grid |
| Spec | ecma-376-5-part-1 § 18.8.20 patternFill |
| ID / part | Predicate | XPath | python-xlsx | xlsxjs |
|---|---|---|---|---|
pattern-light-grid-blue-yellowxl/styles.xml | existThe styles part must contain a <patternFill> with the expected ST_PatternType value. | //x:fills/x:fill/x:patternFill[@patternType='lightGrid'] | — | — |
| ID | Predicate | Selector | python-xlsx | xlsxjs |
|---|---|---|---|---|
cell-text-light-grid-blue-yellow | css_selector/ existThe rendered sheet must contain the cell with the pattern fill applied. | section.xlsx td | — | pass |
sheet-count-light-grid | css_selector/ equal-countExactly one rendered sheet section per case. Catches renderers that emit zero sheets (hard failure). | section.xlsx | — | — |
scripts/gen_cell_fill_pattern.py
#!/usr/bin/env python3
"""Generate a fixtures/xlsx/cell-fill-pattern--<color>--<pattern>.xlsx fixture."""
from __future__ import annotations
import argparse
import datetime as _dt
from pathlib import Path
from xlsx import Workbook
from xlsx.styles import PatternFill
_REPRODUCIBLE_DT = _dt.datetime(2000, 1, 1, 0, 0, 0)
_REPO_ROOT = Path(__file__).resolve().parent.parent
def main() -> int:
parser = argparse.ArgumentParser()
parser.add_argument("--pattern", required=True)
parser.add_argument("--fg", required=True)
parser.add_argument("--bg", required=True)
parser.add_argument("--out", required=True)
args = parser.parse_args()
out_path = Path(args.out)
if not out_path.is_absolute():
out_path = _REPO_ROOT / out_path
wb = Workbook()
ws = wb.active
ws["A1"] = "Filled cell"
ws["A1"].fill = PatternFill(
patternType=args.pattern,
fgColor=args.fg,
bgColor=args.bg,
)
out_path.parent.mkdir(parents=True, exist_ok=True)
wb.save(out_path, zip_date_time=_REPRODUCIBLE_DT)
print(out_path)
return 0
if __name__ == "__main__":
raise SystemExit(main())
{
"$schema": "../manifest.schema.json",
"id": "xlsx/cell-fill-pattern--blue-yellow--light-grid",
"kind": "literal",
"title": "Cell fill pattern (16 ST_PatternType values x 5 colour pairs)",
"format": "xlsx",
"category": "cell-formatting",
"summary": "A workbook applies a <patternFill> to cell A1 using each of the 16 ST_PatternType values that carry foreground/background colours, paired with five colour families.",
"spec": {
"source": "ecma-376-5-part-1",
"clause": "18.8.20",
"element": "patternFill",
"rnc_reference": "spec/ecma-376-5/part-1/rnc/SpreadsheetML.rnc",
"xsd_reference": "spec/ecma-376-5/part-1/xsd/sml.xsd",
"notes": "ST_PatternType (ECMA-376 Part 1 clause 18.18.55) defines 19 pattern type values for <patternFill>. This manifest covers the 16 that accept foreground and background colours: solid, mediumGray, darkGray, lightGray, darkHorizontal, darkVertical, darkDown, darkUp, darkGrid, darkTrellis, lightHorizontal, lightVertical, lightDown, lightUp, lightGrid, lightTrellis. The three omitted values (none, gray0625, gray125) are pattern-only and do not meaningfully carry colours. Each pattern is paired with five colour families (fg/bg hex pairs). One manifest file expands into 16 x 5 = 80 concrete fixture cases. Axis ordering is alphabetised by ooxml_validate.expand_manifest, so fixture names are `<id>--<color.id>--<pattern.id>`."
},
"fixtures": {
"machine": "xlsx/cell-fill-pattern--blue-yellow--light-grid"
},
"generator": {
"python": "scripts/gen_cell_fill_pattern.py",
"arg_template": "--pattern {pattern.val} --fg {color.fg} --bg {color.bg} --out fixtures/xlsx/cell-fill-pattern--{color.id}--{pattern.id}.xlsx"
},
"_expansion": {
"parent_id": "xlsx/cell-fill-pattern",
"bindings": {
"color": "blue-yellow",
"pattern": "light-grid"
}
},
"assertions": [
{
"id": "pattern-light-grid-blue-yellow",
"part": "xl/styles.xml",
"namespaces": {
"x": "http://schemas.openxmlformats.org/spreadsheetml/2006/main"
},
"xpath": "//x:fills/x:fill/x:patternFill[@patternType='lightGrid']",
"must": "exist",
"description": "The styles part must contain a <patternFill> with the expected ST_PatternType value."
}
],
"render_assertions": [
{
"id": "cell-text-light-grid-blue-yellow",
"kind": "css_selector",
"selector": "section.xlsx td",
"must": "exist",
"description": "The rendered sheet must contain the cell with the pattern fill applied."
},
{
"id": "sheet-count-light-grid",
"kind": "css_selector",
"selector": "section.xlsx",
"must": "equal-count",
"count": 1,
"description": "Exactly one rendered sheet section per case. Catches renderers that emit zero sheets (hard failure)."
}
]
}
