Apply each of four ST_VerticalAlignment values to cell A1; the value appears in xl/styles.xml as <cellXfs>/<xf>/<alignment>/@vertical.
Library verdicts: python-xlsx: — xlsxjs: —
| Feature id | xlsx/cell-alignment-vertical--justify |
|---|---|
| Format | xlsx |
| Category | cell-formatting |
| Family | xlsx/cell-alignment-vertical |
| Axis values | align=justify |
| Spec | ecma-376-5-part-1 § 18.8.1 alignment |
| ID / part | Predicate | XPath | python-xlsx | xlsxjs |
|---|---|---|---|---|
vertical-alignment-justifyxl/styles.xml | equal = justifyA <cellXfs>/<xf>/<alignment>/@vertical attribute must carry the expected ST_VerticalAlignment value. | //x:cellXfs/x:xf/x:alignment/@vertical | — | — |
| ID | Predicate | Selector | python-xlsx | xlsxjs |
|---|---|---|---|---|
cell-alignment-vertical-justify-cell-present | css_selector/ existThe rendered sheet must contain the aligned cell. | section.xlsx td | — | — |
sheet-count-justify | css_selector/ equal-countExactly one rendered sheet section per case. Catches renderers that emit zero sheets (hard failure). | section.xlsx | — | — |
cell-alignment-vertical-justify-computed-vertical-align | computed_style = {align.css_re} style=vertical-alignAccessibility/semantics: the computed vertical-align on the rendered table cell should reflect the authored ST_VerticalAlignment. 'top'/'bottom' map to the same CSS names; ST_VerticalAlignment 'center' maps to CSS 'middle' (either literal is accepted); 'justify' has no canonical CSS parallel and accepts anything. | section.xlsx td, section.xlsx th | — | — |
scripts/gen_cell_alignment_vertical.py
#!/usr/bin/env python3
"""Generate a ``fixtures/xlsx/cell-alignment-vertical--<id>.xlsx`` fixture.
Parameterised generator for the ``xlsx/cell-alignment-vertical``
manifest. Writes a minimal one-sheet workbook with cell A1 carrying a
text value and ``Alignment(vertical=<val>)`` applied to it.
python-xlsx emits the setting as
``<alignment vertical=\"<val>\"/>`` on the corresponding
``<cellXfs>/<xf>`` entry in xl/styles.xml.
"""
from __future__ import annotations
import argparse
import datetime as _dt
from pathlib import Path
from xlsx import Workbook
from xlsx.styles import Alignment
_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("--align", required=True, help="ST_VerticalAlignment value")
parser.add_argument("--out", required=True, help="Output fixture path")
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"] = f"v={args.align}"
ws["A1"].alignment = Alignment(vertical=args.align)
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-alignment-vertical--justify",
"kind": "literal",
"title": "Cell vertical alignment (4 ST_VerticalAlignment values)",
"format": "xlsx",
"category": "cell-formatting",
"summary": "Apply each of four ST_VerticalAlignment values to cell A1; the value appears in xl/styles.xml as <cellXfs>/<xf>/<alignment>/@vertical.",
"spec": {
"source": "ecma-376-5-part-1",
"clause": "18.8.1",
"element": "alignment",
"rnc_reference": "spec/ecma-376-5/part-1/rnc/SpreadsheetML.rnc",
"xsd_reference": "spec/ecma-376-5/part-1/xsd/sml.xsd",
"notes": "ECMA-376 Part 1 clause 18.18.88 defines ST_VerticalAlignment with five values: top, center, bottom, justify, distributed. SpreadsheetML carries the setting on a <alignment vertical=\"<val>\"/> child of an <xf> record in <cellXfs> (clause 18.8.1). This manifest covers four of the five values — top/center/bottom/justify — the canonical Excel dropdown picks; ``distributed`` is exercised separately. All four values round-trip through python-xlsx verbatim. SpreadsheetML parts use a default namespace with no prefix; XPath needs an explicit binding (here 'x'). One manifest file expands into 4 concrete fixture cases."
},
"fixtures": {
"machine": "xlsx/cell-alignment-vertical--justify"
},
"generator": {
"python": "scripts/gen_cell_alignment_vertical.py",
"arg_template": "--align {align.val} --out fixtures/xlsx/cell-alignment-vertical--{align.id}.xlsx"
},
"_expansion": {
"parent_id": "xlsx/cell-alignment-vertical",
"bindings": {
"align": "justify"
}
},
"assertions": [
{
"id": "vertical-alignment-justify",
"part": "xl/styles.xml",
"namespaces": {
"x": "http://schemas.openxmlformats.org/spreadsheetml/2006/main"
},
"xpath": "//x:cellXfs/x:xf/x:alignment/@vertical",
"must": "equal",
"value": "justify",
"description": "A <cellXfs>/<xf>/<alignment>/@vertical attribute must carry the expected ST_VerticalAlignment value."
}
],
"render_assertions": [
{
"id": "cell-alignment-vertical-justify-cell-present",
"kind": "css_selector",
"selector": "section.xlsx td",
"must": "exist",
"description": "The rendered sheet must contain the aligned cell."
},
{
"id": "sheet-count-justify",
"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)."
},
{
"id": "cell-alignment-vertical-justify-computed-vertical-align",
"kind": "computed_style",
"selector": "section.xlsx td, section.xlsx th",
"style_property": "vertical-align",
"value": "{align.css_re}",
"description": "Accessibility/semantics: the computed vertical-align on the rendered table cell should reflect the authored ST_VerticalAlignment. 'top'/'bottom' map to the same CSS names; ST_VerticalAlignment 'center' maps to CSS 'middle' (either literal is accepted); 'justify' has no canonical CSS parallel and accepts anything."
}
]
}
