xlsx/cell-border-style

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.

Cases (48)

Feature IDAxis bindingspython-xlsxxlsxjs
xlsx/cell-border-style--bottom--dashDotside=bottom, style=dashDot
xlsx/cell-border-style--bottom--dashDotDotside=bottom, style=dashDotDot
xlsx/cell-border-style--bottom--dashedside=bottom, style=dashed
xlsx/cell-border-style--bottom--dottedside=bottom, style=dotted
xlsx/cell-border-style--bottom--doubleside=bottom, style=double
xlsx/cell-border-style--bottom--hairside=bottom, style=hair
xlsx/cell-border-style--bottom--mediumside=bottom, style=medium
xlsx/cell-border-style--bottom--mediumDashDotside=bottom, style=mediumDashDot
xlsx/cell-border-style--bottom--mediumDashDotDotside=bottom, style=mediumDashDotDot
xlsx/cell-border-style--bottom--mediumDashedside=bottom, style=mediumDashed
xlsx/cell-border-style--bottom--thickside=bottom, style=thick
xlsx/cell-border-style--bottom--thinside=bottom, style=thin
xlsx/cell-border-style--left--dashDotside=left, style=dashDot
xlsx/cell-border-style--left--dashDotDotside=left, style=dashDotDot
xlsx/cell-border-style--left--dashedside=left, style=dashed
xlsx/cell-border-style--left--dottedside=left, style=dotted
xlsx/cell-border-style--left--doubleside=left, style=double
xlsx/cell-border-style--left--hairside=left, style=hair
xlsx/cell-border-style--left--mediumside=left, style=medium
xlsx/cell-border-style--left--mediumDashDotside=left, style=mediumDashDot
xlsx/cell-border-style--left--mediumDashDotDotside=left, style=mediumDashDotDot
xlsx/cell-border-style--left--mediumDashedside=left, style=mediumDashed
xlsx/cell-border-style--left--thickside=left, style=thick
xlsx/cell-border-style--left--thinside=left, style=thin
xlsx/cell-border-style--right--dashDotside=right, style=dashDot
xlsx/cell-border-style--right--dashDotDotside=right, style=dashDotDot
xlsx/cell-border-style--right--dashedside=right, style=dashed
xlsx/cell-border-style--right--dottedside=right, style=dotted
xlsx/cell-border-style--right--doubleside=right, style=double
xlsx/cell-border-style--right--hairside=right, style=hair
xlsx/cell-border-style--right--mediumside=right, style=medium
xlsx/cell-border-style--right--mediumDashDotside=right, style=mediumDashDot
xlsx/cell-border-style--right--mediumDashDotDotside=right, style=mediumDashDotDot
xlsx/cell-border-style--right--mediumDashedside=right, style=mediumDashed
xlsx/cell-border-style--right--thickside=right, style=thick
xlsx/cell-border-style--right--thinside=right, style=thin
xlsx/cell-border-style--top--dashDotside=top, style=dashDot
xlsx/cell-border-style--top--dashDotDotside=top, style=dashDotDot
xlsx/cell-border-style--top--dashedside=top, style=dashed
xlsx/cell-border-style--top--dottedside=top, style=dotted
xlsx/cell-border-style--top--doubleside=top, style=double
xlsx/cell-border-style--top--hairside=top, style=hair
xlsx/cell-border-style--top--mediumside=top, style=medium
xlsx/cell-border-style--top--mediumDashDotside=top, style=mediumDashDot
xlsx/cell-border-style--top--mediumDashDotDotside=top, style=mediumDashDotDot
xlsx/cell-border-style--top--mediumDashedside=top, style=mediumDashed
xlsx/cell-border-style--top--thickside=top, style=thick
xlsx/cell-border-style--top--thinside=top, style=thin

Aggregate

LibraryPassFailPending
python-xlsx0048
xlsxjs0048

Parameter axes

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

Generator source

scripts/gen_cell_border_style.py — runs with --arg_template --style {style.val} --side {side.attr} --out fixtures/xlsx/cell-border-style--{side.id}--{style.id}.xlsx

#!/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())

Manifest (parent, unexpanded)

{
  "$schema": "../manifest.schema.json",
  "id": "xlsx/cell-border-style",
  "kind": "parameterised",
  "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"
  },
  "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"
  },
  "parameters": {
    "style": [
      {
        "id": "thin",
        "val": "thin"
      },
      {
        "id": "medium",
        "val": "medium"
      },
      {
        "id": "thick",
        "val": "thick"
      },
      {
        "id": "dashed",
        "val": "dashed"
      },
      {
        "id": "dotted",
        "val": "dotted"
      },
      {
        "id": "double",
        "val": "double"
      },
      {
        "id": "hair",
        "val": "hair"
      },
      {
        "id": "mediumDashed",
        "val": "mediumDashed"
      },
      {
        "id": "dashDot",
        "val": "dashDot"
      },
      {
        "id": "mediumDashDot",
        "val": "mediumDashDot"
      },
      {
        "id": "dashDotDot",
        "val": "dashDotDot"
      },
      {
        "id": "mediumDashDotDot",
        "val": "mediumDashDotDot"
      }
    ],
    "side": [
      {
        "id": "top",
        "attr": "top"
      },
      {
        "id": "left",
        "attr": "left"
      },
      {
        "id": "bottom",
        "attr": "bottom"
      },
      {
        "id": "right",
        "attr": "right"
      }
    ]
  },
  "assertions_template": [
    {
      "id": "{side.id}-border-is-{style.id}",
      "part": "xl/styles.xml",
      "namespaces": {
        "x": "http://schemas.openxmlformats.org/spreadsheetml/2006/main"
      },
      "xpath": "//x:borders/x:border/x:{side.attr}/@style",
      "must": "equal",
      "value": "{style.val}",
      "description": "The cell's border {side.attr} edge must declare line style '{style.val}'."
    }
  ]
}