xlsx/row-height

A workbook sizes row 1 of the first worksheet to 40 points via the row element's ht and customHeight attributes.

Library verdicts: python-xlsx: — xlsxjs: pass

Metadata

Feature idxlsx/row-height
Formatxlsx
Categorysheet-layout
Spececma-376-5-part-1 § 18.3.1.73 row

XPath assertions

ID / partPredicateXPathpython-xlsxxlsxjs
row-ht-40
xl/worksheets/sheet1.xml
match = ^40(\.0+)?$
Row 1 must declare @ht='40' (optionally with trailing decimal zeros).
string(//x:sheetData/x:row[@r='1']/@ht)
row-custom-height
xl/worksheets/sheet1.xml
exist
Row 1 must carry @customHeight='1' alongside @ht to flag the override.
//x:sheetData/x:row[@r='1' and @customHeight='1']

Render assertions

IDPredicateSelectorpython-xlsxxlsxjs
row-height-text-presentcss_selector/ match-text = Tall row
The rendered sheet must contain a cell with the fixture text.
section.xlsx td, section.xlsx thpass
row-height-tallcomputed_style = ^(4[0-9]|5[0-9]|6[0-9])(\.[0-9]+)?px$ style=height
The row tr element's computed height must be roughly 40-69px (40pt ~= 53px at 96dpi; accept a window around the target).
section.xlsx trpass
sheet-countcss_selector/ equal-count
Exactly one rendered sheet section. Catches renderers that emit zero sheets (hard failure) or duplicate a sheet.
section.xlsx

Generator source

scripts/gen_row_height.py

#!/usr/bin/env python3
"""Generate ``fixtures/xlsx/row-height.xlsx``.

A minimal one-sheet workbook with cell A1 containing ``Tall row`` and
row 1 sized to 40 points. Designed to satisfy the assertions in
``features/xlsx/row-height.json``.
"""

from __future__ import annotations

from pathlib import Path

from xlsx import Workbook

import datetime as _dt
_REPRODUCIBLE_DT = _dt.datetime(2000, 1, 1, 0, 0, 0)

_REPO_ROOT = Path(__file__).resolve().parent.parent
_OUT = _REPO_ROOT / "fixtures" / "xlsx" / "row-height.xlsx"


def main() -> int:
    wb = Workbook()
    ws = wb.active
    ws["A1"] = "Tall row"
    ws.row_dimensions[1].height = 40
    _OUT.parent.mkdir(parents=True, exist_ok=True)
    wb.save(_OUT, zip_date_time=_REPRODUCIBLE_DT)
    print(_OUT)
    return 0


if __name__ == "__main__":
    raise SystemExit(main())

Manifest (expanded)

{
  "$schema": "../manifest.schema.json",
  "id": "xlsx/row-height",
  "title": "Row height (40 points)",
  "format": "xlsx",
  "category": "sheet-layout",
  "summary": "A workbook sizes row 1 of the first worksheet to 40 points via the row element's ht and customHeight attributes.",
  "spec": {
    "source": "ecma-376-5-part-1",
    "clause": "18.3.1.73",
    "element": "row",
    "rnc_reference": "spec/ecma-376-5/part-1/rnc/SpreadsheetML.rnc",
    "xsd_reference": "spec/ecma-376-5/part-1/xsd/sml.xsd",
    "notes": "Row height in SpreadsheetML lives on the <row> element in <sheetData> as @ht (height in points) paired with @customHeight='1' to signal the user overrode the sheet default. Without customHeight, Word/Excel may treat ht as advisory. python-xlsx emits both when row_dimensions[n].height is set. SpreadsheetML parts use a default namespace with no prefix; XPath therefore needs an explicit binding (here 'x')."
  },
  "fixtures": {
    "machine": "xlsx/row-height",
    "office": "xlsx/row-height"
  },
  "generator": {
    "python": "scripts/gen_row_height.py"
  },
  "assertions": [
    {
      "id": "row-ht-40",
      "part": "xl/worksheets/sheet1.xml",
      "namespaces": {
        "x": "http://schemas.openxmlformats.org/spreadsheetml/2006/main"
      },
      "xpath": "string(//x:sheetData/x:row[@r='1']/@ht)",
      "must": "match",
      "value": "^40(\\.0+)?$",
      "description": "Row 1 must declare @ht='40' (optionally with trailing decimal zeros)."
    },
    {
      "id": "row-custom-height",
      "part": "xl/worksheets/sheet1.xml",
      "namespaces": {
        "x": "http://schemas.openxmlformats.org/spreadsheetml/2006/main"
      },
      "xpath": "//x:sheetData/x:row[@r='1' and @customHeight='1']",
      "must": "exist",
      "description": "Row 1 must carry @customHeight='1' alongside @ht to flag the override."
    }
  ],
  "render_assertions": [
    {
      "id": "row-height-text-present",
      "kind": "css_selector",
      "selector": "section.xlsx td, section.xlsx th",
      "must": "match-text",
      "value": "Tall row",
      "description": "The rendered sheet must contain a cell with the fixture text."
    },
    {
      "id": "row-height-tall",
      "kind": "computed_style",
      "selector": "section.xlsx tr",
      "style_property": "height",
      "value": "^(4[0-9]|5[0-9]|6[0-9])(\\.[0-9]+)?px$",
      "description": "The row tr element's computed height must be roughly 40-69px (40pt ~= 53px at 96dpi; accept a window around the target)."
    },
    {
      "id": "sheet-count",
      "kind": "css_selector",
      "selector": "section.xlsx",
      "must": "equal-count",
      "count": 1,
      "description": "Exactly one rendered sheet section. Catches renderers that emit zero sheets (hard failure) or duplicate a sheet."
    }
  ]
}

Fixture

Download row-height.xlsx (4.7 KB)

Reference preview

Reference (machine, page 1 PNG)

xlsx/row-height page 1 reference

Reference PDF


Download PDF Open in PDF.js

Spec notes

Row height in SpreadsheetML lives on the <row> element in <sheetData> as @ht (height in points) paired with @customHeight='1' to signal the user overrode the sheet default. Without customHeight, Word/Excel may treat ht as advisory. python-xlsx emits both when row_dimensions[n].height is set. SpreadsheetML parts use a default namespace with no prefix; XPath therefore needs an explicit binding (here 'x').