Skip to content

XLV-5: row-height overrides in javascript-excel/render (auto-fit) - #102

Merged
securedeveloper merged 2 commits into
mainfrom
xlv-5-row-heights
Nov 16, 2026
Merged

securedeveloper merged 2 commits into
mainfrom
xlv-5-row-heights

Conversation

@securedeveloper

@securedeveloper securedeveloper commented Nov 16, 2026 •

Copy link
Copy Markdown
Owner

XLV-5 (engine): row-height overrides in javascript-excel/render, so react-xlsx-viewer can auto-fit rows (react-xlsx-viewer issue #14, design in its comments; decision Q11).

export function hasStoredRowHeight(s: RenderSheet, row: number): boolean;
export function setRowHeights(s: RenderSheet, heights: ReadonlyArray<readonly [row: number, px: number]>): boolean;
  • What it changes: setRowHeights takes measured heights in CSS px at zoom 100 % and rebuilds the Float64Array prefix sums from the first changed row onwards, at O(rows after it) per batch. It returns whether anything changed.
  • What it ignores:
    • rows with a stored height (rowProps[r].height): the file's height wins, as in Excel;
    • hidden rows, rows outside the extent, and non-finite values.
  • Clamping: heights are clamped to [default row height, 409 pt], so auto-fit only grows rows.
  • What it leaves alone: the workbook model and the cell cache; cells don't depend on row heights.
  • Docs: docs/api.md §5.8.1 adds both functions and an "Auto-fit" note.
  • Consumer fixture: it now type-checks both functions, and the entries test lists them.

Why an array, not an Iterable: the first push used Iterable and Consumer TS failed. Iterable is an ES2015 lib type, and consumers on TS 5.x in bundler mode default to ES5 libs. ReadonlyArray works everywhere. Consumer TS 5.0/5.4/7.0 × 3 resolutions pass locally.

Tests (test/render/render.test.ts, 3 new): stored-height detection; growing rows and rebuilding offsets (rowTop, rowHeight, rowAt); the ignored cases; clamping to the default and to 409 pt.

Checked locally (Node 26.13.1): typecheck clean, npm test 863 passed, publint, smoke (tsc node16/nodenext/bundler), docs snippets and the API reference.

Minor changeset (pre mode: the next 2.0 alpha). No new dependencies. The viewer PR, which measures and calls setRowHeights, follows in react-xlsx-viewer.

@securedeveloper
securedeveloper merged commit 8600c27 into main Nov 16, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant