Each ST_BorderStyle line style applied to a single edge of a cell border (top / left / bottom / right). Expands to 12 styles x 4 sides = 48 cases.
Library verdicts: python-xlsx: — xlsxjs: —
| Feature id | xlsx/cell-border-style--bottom--dotted |
|---|---|
| Format | xlsx |
| Category | cell-formatting |
| Family | xlsx/cell-border-style |
| Axis values | side=bottom, style=dotted |
| Spec | ecma-376-5-part-1 § 18.8.3 border |
| ID / part | Predicate | XPath | python-xlsx | xlsxjs |
|---|---|---|---|---|
bottom-border-is-dottedxl/styles.xml | equal = dottedThe cell's border bottom edge must declare line style 'dotted'. | //x:borders/x:border/x:bottom/@style | — | — |
No render assertions declared.
scripts/gen_cell_border_style.py
#!/usr/bin/env python3
"""Generate ``fixtures/xlsx/cell-border-style--<side>--<style>.xlsx``.
Parameterised generator for the ``xlsx/cell-border-style`` family: writes
a single-cell workbook whose ``<border>`` in ``xl/styles.xml`` declares a
single edge (top / left / bottom / right) with the requested
``ST_BorderStyle`` line style. Expanded at runtime by the manifest's
``generator.arg_template`` into 12 styles x 4 sides = 48 cases.
ECMA-376 Part 1 clause 18.8.3 enumerates ``ST_BorderStyle``. The
``none`` value is omitted from the style axis because ``xlsx.styles.Side``
coerces ``'none'`` to Python ``None``, which emits a bare ``<top/>``
without a ``@style`` attribute.
"""
from __future__ import annotations
import argparse
import datetime as _dt
from pathlib import Path
from xlsx import Workbook
from xlsx.styles import Border, Side
_REPO_ROOT = Path(__file__).resolve().parent.parent
_REPRODUCIBLE_DT = _dt.datetime(2000, 1, 1, 0, 0, 0)
_VALID_SIDES = {"top", "left", "bottom", "right"}
def _write(style_val: str, side: str, out: Path) -> None:
if side not in _VALID_SIDES:
raise ValueError(
f"Unknown side {side!r}; expected one of {sorted(_VALID_SIDES)}"
)
wb = Workbook()
ws = wb.active
ws["A1"] = "Border test"
side_obj = Side(border_style=style_val, color="000000")
border_kwargs = {side: side_obj}
ws["A1"].border = Border(**border_kwargs)
out.parent.mkdir(parents=True, exist_ok=True)
wb.save(out, zip_date_time=_REPRODUCIBLE_DT)
def main() -> int:
parser = argparse.ArgumentParser()
parser.add_argument(
"--style", required=True, help="ST_BorderStyle val, e.g. 'thin'"
)
parser.add_argument(
"--side",
required=True,
help="Edge element local name: top | left | bottom | right",
)
parser.add_argument("--out", required=True, help="Output .xlsx path")
args = parser.parse_args()
out_path = Path(args.out)
if not out_path.is_absolute():
out_path = _REPO_ROOT / out_path
_write(args.style, args.side, out_path)
print(out_path)
return 0
if __name__ == "__main__":
raise SystemExit(main())
{
"$schema": "../manifest.schema.json",
"id": "xlsx/cell-border-style--bottom--dotted",
"kind": "literal",
"title": "Cell border style (12 ST_BorderStyle values x 4 sides)",
"format": "xlsx",
"category": "cell-formatting",
"summary": "Each ST_BorderStyle line style applied to a single edge of a cell border (top / left / bottom / right). Expands to 12 styles x 4 sides = 48 cases.",
"spec": {
"source": "ecma-376-5-part-1",
"clause": "18.8.3",
"element": "border",
"rnc_reference": "spec/ecma-376-5/part-1/rnc/SpreadsheetML.rnc",
"xsd_reference": "spec/ecma-376-5/part-1/xsd/sml.xsd",
"notes": "<border> inside <borders> in xl/styles.xml carries per-edge border child elements (left, right, top, bottom, diagonal). Each child's @style attribute is an ST_BorderStyle line style. ECMA-376 Part 1 clause 18.18.3 enumerates ST_BorderStyle. This family covers 12 of those values on the four outer edges. 'none' is omitted because python-xlsx coerces border_style='none' to Python None and emits a bare edge element with no @style attribute, so the equal-match assertion fails spuriously. Axis ordering is alphabetised by ooxml_validate.expand_manifest, so fixture names are `<id>--<side.id>--<style.id>`."
},
"fixtures": {
"machine": "xlsx/cell-border-style--bottom--dotted"
},
"generator": {
"python": "scripts/gen_cell_border_style.py",
"arg_template": "--style {style.val} --side {side.attr} --out fixtures/xlsx/cell-border-style--{side.id}--{style.id}.xlsx"
},
"_expansion": {
"parent_id": "xlsx/cell-border-style",
"bindings": {
"side": "bottom",
"style": "dotted"
}
},
"assertions": [
{
"id": "bottom-border-is-dotted",
"part": "xl/styles.xml",
"namespaces": {
"x": "http://schemas.openxmlformats.org/spreadsheetml/2006/main"
},
"xpath": "//x:borders/x:border/x:bottom/@style",
"must": "equal",
"value": "dotted",
"description": "The cell's border bottom edge must declare line style 'dotted'."
}
]
}
