A workbook defines a solid-pattern <fill> with a yellow foreground RGB in its styles part and applies it to cell A1.
Library verdicts: python-xlsx: — xlsxjs: pass
| Feature id | xlsx/cell-fill-color |
|---|---|
| Format | xlsx |
| Category | cell-formatting |
| Spec | ecma-376-5-part-1 § 18.8.20 fill |
| ID / part | Predicate | XPath | python-xlsx | xlsxjs |
|---|---|---|---|---|
solid-fill-yellowxl/styles.xml | match = ^([0-9A-Fa-f]{2})?FFFF00$At least one solid <patternFill> must have an <fgColor rgb='FFFF00'/> (optionally prefixed with a 2-char AA alpha byte). | string(//x:fills/x:fill/x:patternFill[@patternType='solid']/x:fgColor/@rgb) | — | — |
shared-string-presentxl/sharedStrings.xml | existThe shared-strings table must contain 'Yellow cell'. | //x:sst/x:si/x:t[normalize-space()='Yellow cell'] | — | — |
| ID | Predicate | Selector | python-xlsx | xlsxjs |
|---|---|---|---|---|
cell-fill-text-present | css_selector/ match-text = Yellow cellThe rendered sheet must contain a cell with the fixture text. | section.xlsx td, section.xlsx th | — | pass |
cell-fill-is-yellow | computed_style = ^rgba?\(\s*255\s*,\s*255\s*,\s*0\s*(,\s*[0-9.]+\s*)?\)$ style=background-colorThe computed background-color on the cell must resolve to yellow (rgb 255,255,0). | section.xlsx td, section.xlsx th | — | pass |
sheet-count | css_selector/ equal-countExactly one rendered sheet section. Catches renderers that emit zero sheets (hard failure) or duplicate a sheet. | section.xlsx | — | — |
scripts/gen_cell_fill_color.py
#!/usr/bin/env python3
"""Generate ``fixtures/xlsx/cell-fill-color.xlsx``.
A minimal one-sheet workbook with cell A1 containing ``Yellow cell``
with a solid yellow (FFFF00) pattern fill. Designed to satisfy the
assertions in ``features/xlsx/cell-fill-color.json``.
"""
from __future__ import annotations
from pathlib import Path
from xlsx import Workbook
from xlsx.styles import PatternFill
import datetime as _dt
_REPRODUCIBLE_DT = _dt.datetime(2000, 1, 1, 0, 0, 0)
_REPO_ROOT = Path(__file__).resolve().parent.parent
_OUT = _REPO_ROOT / "fixtures" / "xlsx" / "cell-fill-color.xlsx"
def main() -> int:
wb = Workbook()
ws = wb.active
ws["A1"] = "Yellow cell"
ws["A1"].fill = PatternFill(
start_color="FFFF00", end_color="FFFF00", fill_type="solid"
)
_OUT.parent.mkdir(parents=True, exist_ok=True)
wb.save(_OUT, zip_date_time=_REPRODUCIBLE_DT)
print(_OUT)
return 0
if __name__ == "__main__":
raise SystemExit(main())
{
"$schema": "../manifest.schema.json",
"id": "xlsx/cell-fill-color",
"title": "Cell fill color (solid yellow)",
"format": "xlsx",
"category": "cell-formatting",
"summary": "A workbook defines a solid-pattern <fill> with a yellow foreground RGB in its styles part and applies it to cell A1.",
"spec": {
"source": "ecma-376-5-part-1",
"clause": "18.8.20",
"element": "fill",
"rnc_reference": "spec/ecma-376-5/part-1/rnc/SpreadsheetML.rnc",
"xsd_reference": "spec/ecma-376-5/part-1/xsd/sml.xsd",
"notes": "Cell fill colors in SpreadsheetML live inside <fills> in xl/styles.xml as <fill><patternFill patternType=\"solid\"><fgColor rgb=\"...\"/>...</patternFill></fill> entries. A <xf> record in <cellXfs> then references that fillId. Excel's ST_UnsignedIntHex encoding writes fgColor/@rgb as an 8-char AARRGGBB value (or sometimes 6-char RRGGBB); python-xlsx emits '00FFFF00' (alpha=00). The regex accepts either a 6-char or 8-char form with any 2-char alpha prefix. SpreadsheetML parts use a default namespace with no prefix; XPath therefore needs an explicit binding (here 'x')."
},
"fixtures": {
"machine": "xlsx/cell-fill-color",
"office": "xlsx/cell-fill-color"
},
"generator": {
"python": "scripts/gen_cell_fill_color.py"
},
"assertions": [
{
"id": "solid-fill-yellow",
"part": "xl/styles.xml",
"namespaces": {
"x": "http://schemas.openxmlformats.org/spreadsheetml/2006/main"
},
"xpath": "string(//x:fills/x:fill/x:patternFill[@patternType='solid']/x:fgColor/@rgb)",
"must": "match",
"value": "^([0-9A-Fa-f]{2})?FFFF00$",
"description": "At least one solid <patternFill> must have an <fgColor rgb='FFFF00'/> (optionally prefixed with a 2-char AA alpha byte)."
},
{
"id": "shared-string-present",
"part": "xl/sharedStrings.xml",
"namespaces": {
"x": "http://schemas.openxmlformats.org/spreadsheetml/2006/main"
},
"xpath": "//x:sst/x:si/x:t[normalize-space()='Yellow cell']",
"must": "exist",
"description": "The shared-strings table must contain 'Yellow cell'."
}
],
"render_assertions": [
{
"id": "cell-fill-text-present",
"kind": "css_selector",
"selector": "section.xlsx td, section.xlsx th",
"must": "match-text",
"value": "Yellow cell",
"description": "The rendered sheet must contain a cell with the fixture text."
},
{
"id": "cell-fill-is-yellow",
"kind": "computed_style",
"selector": "section.xlsx td, section.xlsx th",
"style_property": "background-color",
"value": "^rgba?\\(\\s*255\\s*,\\s*255\\s*,\\s*0\\s*(,\\s*[0-9.]+\\s*)?\\)$",
"description": "The computed background-color on the cell must resolve to yellow (rgb 255,255,0)."
},
{
"id": "sheet-count",
"kind": "css_selector",
"selector": "section.xlsx",
"must": "equal-count",
"count": 1,
"description": "Exactly one rendered sheet section. Catches renderers that emit zero sheets (hard failure) or duplicate a sheet."
}
]
}
