xlsx/cell-alignment-vertical--bottom

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: —

Metadata

Feature idxlsx/cell-alignment-vertical--bottom
Formatxlsx
Categorycell-formatting
Familyxlsx/cell-alignment-vertical
Axis valuesalign=bottom
Spececma-376-5-part-1 § 18.8.1 alignment

XPath assertions

ID / partPredicateXPathpython-xlsxxlsxjs
vertical-alignment-bottom
xl/styles.xml
equal = bottom
A <cellXfs>/<xf>/<alignment>/@vertical attribute must carry the expected ST_VerticalAlignment value.
//x:cellXfs/x:xf/x:alignment/@vertical

Render assertions

IDPredicateSelectorpython-xlsxxlsxjs
cell-alignment-vertical-bottom-cell-presentcss_selector/ exist
The rendered sheet must contain the aligned cell.
section.xlsx td
sheet-count-bottomcss_selector/ equal-count
Exactly one rendered sheet section per case. Catches renderers that emit zero sheets (hard failure).
section.xlsx
cell-alignment-vertical-bottom-computed-vertical-aligncomputed_style = {align.css_re} style=vertical-align
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.
section.xlsx td, section.xlsx th

Generator source

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())

Manifest (expanded)

{
  "$schema": "../manifest.schema.json",
  "id": "xlsx/cell-alignment-vertical--bottom",
  "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--bottom"
  },
  "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": "bottom"
    }
  },
  "assertions": [
    {
      "id": "vertical-alignment-bottom",
      "part": "xl/styles.xml",
      "namespaces": {
        "x": "http://schemas.openxmlformats.org/spreadsheetml/2006/main"
      },
      "xpath": "//x:cellXfs/x:xf/x:alignment/@vertical",
      "must": "equal",
      "value": "bottom",
      "description": "A <cellXfs>/<xf>/<alignment>/@vertical attribute must carry the expected ST_VerticalAlignment value."
    }
  ],
  "render_assertions": [
    {
      "id": "cell-alignment-vertical-bottom-cell-present",
      "kind": "css_selector",
      "selector": "section.xlsx td",
      "must": "exist",
      "description": "The rendered sheet must contain the aligned cell."
    },
    {
      "id": "sheet-count-bottom",
      "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-bottom-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."
    }
  ]
}

Fixture

Download cell-alignment-vertical--bottom.xlsx (4.8 KB)

Reference preview

Reference (machine, page 1 PNG)

xlsx/cell-alignment-vertical--bottom page 1 reference

Reference PDF


Download PDF Open in PDF.js

Spec 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.