A worksheet carries a single <x14:sparklineGroup> in its extLst whose @type covers the three Excel sparkline kinds — line, column, and stacked (the XML spelling of win/loss). Line is Excel's default, so the @type attribute is omitted in that case.
Library verdicts: python-xlsx: — xlsxjs: —
| Feature id | xlsx/sparkline--column |
|---|---|
| Format | xlsx |
| Category | cell-formatting |
| Family | xlsx/sparkline |
| Axis values | type=column |
| Spec | ecma-376-5-part-1 § 18.3.1.76 sparklineGroup |
| ID / part | Predicate | XPath | python-xlsx | xlsxjs |
|---|---|---|---|---|
sparkline-group-columnxl/worksheets/sheet1.xml | equal = columnThe sheet's extLst must carry an x14:sparklineGroup whose @type matches (or is the default line-sparkline kind with @type omitted). | //x14:sparklineGroup/@type | — | — |
No render assertions declared.
scripts/gen_sparkline.py
#!/usr/bin/env python3
"""Generate ``fixtures/xlsx/sparkline--<id>.xlsx`` fixtures.
Parameterised generator for the ``xlsx/sparkline`` manifest. Writes a
minimal one-sheet workbook with 6 cells of mixed-sign numeric data in
A1:F1, then adds a single :class:`SparklineGroup` containing one
sparkline anchored at G1 whose source is ``Sheet1!A1:F1``. The group
@type is driven from the CLI argument: ``line``, ``column``, or
``stacked`` (the XML spelling of the Excel "Win/Loss" UI label).
python-xlsx emits the payload under ``<worksheet>/<extLst>/<ext
uri='{05C60535-1F16-4fd2-B633-F4F36F0B64E0}'>`` in the x14 extension
namespace. The @type attribute is omitted for the default ``line``
kind, so the manifest's ``line`` case asserts sparklineGroup presence
rather than @type equality.
"""
from __future__ import annotations
import argparse
import datetime as _dt
from pathlib import Path
from xlsx import Workbook
_REPRODUCIBLE_DT = _dt.datetime(2000, 1, 1, 0, 0, 0)
_REPO_ROOT = Path(__file__).resolve().parent.parent
# Mixed-sign row so both column and win-loss sparkline render usefully.
_DATA = (1, -2, 3, -4, 5, -6)
def main() -> int:
parser = argparse.ArgumentParser()
parser.add_argument("--type", required=True,
choices=("line", "column", "stacked"),
help="Sparkline kind (XML enum, not UI label).")
parser.add_argument("--out", required=True)
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.title = "Sheet1"
for j, v in enumerate(_DATA, 1):
ws.cell(row=1, column=j, value=v)
ws.add_sparkline("G1", "Sheet1!A1:F1", type=args.type)
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/sparkline--column",
"kind": "literal",
"title": "Sparkline groups — line / column / winloss",
"format": "xlsx",
"category": "cell-formatting",
"summary": "A worksheet carries a single <x14:sparklineGroup> in its extLst whose @type covers the three Excel sparkline kinds — line, column, and stacked (the XML spelling of win/loss). Line is Excel's default, so the @type attribute is omitted in that case.",
"spec": {
"source": "ecma-376-5-part-1",
"clause": "18.3.1.76",
"element": "sparklineGroup",
"rnc_reference": "spec/ecma-376-5/part-1/rnc/SpreadsheetML.rnc",
"xsd_reference": "spec/ecma-376-5/part-1/xsd/sml.xsd",
"notes": "Sparklines live in the x14 extension namespace (http://schemas.microsoft.com/office/spreadsheetml/2009/9/main) inside <worksheet>/<extLst>/<ext uri='{05C60535-1F16-4fd2-B633-F4F36F0B64E0}'>. Each <x14:sparklineGroup> has a @type that defaults to 'line'; the Excel UI-labelled 'Win/Loss' sparkline maps to the XML enum value 'stacked'. python-xlsx's Worksheet.add_sparkline() accepts type='line'/'column'/'stacked' directly; it omits the @type attribute on the default 'line' path, so the manifest asserts sparklineGroup presence for the line case and @type equality for the other two. Source data is a 6-cell row A1:F1 with mixed-sign numbers so the column and win-loss cases render usefully."
},
"fixtures": {
"machine": "xlsx/sparkline--column"
},
"generator": {
"python": "scripts/gen_sparkline.py",
"arg_template": "--type {type.val} --out fixtures/xlsx/sparkline--{type.id}.xlsx"
},
"_expansion": {
"parent_id": "xlsx/sparkline",
"bindings": {
"type": "column"
}
},
"assertions": [
{
"id": "sparkline-group-column",
"part": "xl/worksheets/sheet1.xml",
"namespaces": {
"x": "http://schemas.openxmlformats.org/spreadsheetml/2006/main",
"x14": "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"
},
"xpath": "//x14:sparklineGroup/@type",
"must": "equal",
"value": "column",
"description": "The sheet's extLst must carry an x14:sparklineGroup whose @type matches (or is the default line-sparkline kind with @type omitted)."
}
]
}
No rendered reference is available for this case.