Repository navigation
XLV-2: javascript-excel/render, the render model (+ resolveColor) - #96
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
XLV-2:
javascript-excel/render, the render model react-xlsx-viewer draws from (its design decision Q2: framework-free, in the engine). The API section is written first, in docs/api.md §5.8. §5.6 is/importand §5.7 is/format.Release timing: the same decision as
/format(Afzal, 2026-11-16):/renderships in 2.0. The minor changeset goes into the next 2.0 prerelease, and the docs say "Part of 2.0". The branch has main merged in, with/import(§5.6) and/format(§5.7), so/renderis §5.8. It also carries #97's wording fix for/format(identical change), so the two merge cleanly in either order.What it provides (docs/api.md §5.8)
sheetExtentis the used range plus a margin (default 50 rows, 10 columns), capped at Excel's grid.sheetSettingsreturns freeze, RTL, grid lines, headers, zoom, active cell, selection and tab colour.rowTop/rowHeight/colLeft/colWidthcome fromFloat64Arrayprefix sums (pt × 96/72; characters to px with the file-width formula andmaxDigitWidth). Hidden rows and columns have size 0.rowAt/colAtbinary-search and never return a hidden index.mergeAtuses a row-bucket index. Covered cells rendernull, and the anchor carriesmerge: { rows, cols }.renderCell, lazy, bounded cache):formathook;formatCellfrom JSE-18: javascript-excel/format, the number-format renderer #92 fits structurally, so there's no dependency on/format. ARGB colours become#RRGGBB. Without a hook,cellTextis used and alignment follows the value type.=plus the formula, with_xlfn./_xlfn._xlws./_xlpm.removed outside string literals.arrayFormulaandnoCachedValueflags are set where they apply.scheme/malformedreasons). Internal locations and defined names resolve to a sheet index and reference.RenderStyles are cached in aWeakMapkeyed by the model's style object. The reader's frozen shared styles therefore resolve once perxf; the test checksa.style === b.styleon a written-then-read file.[to verify]against Excel), with ties to the lower/right cell. Covered merge cells lend the anchor's style, and an empty cell under a bordered cell is drawn for that edge.step(arrow keys, merge-aware, skips hidden),edge(Ctrl+arrow, Excel's data-region rule),lastUsedCell(Ctrl+End).rangeAsTsv: TAB/CRLF, Excel-style quoting, merges once, displayed or raw values.rangeAsHtml: an escaped<table>with inline styles and spans; hostile text and font names are tested.rangeStats: count, numeric count, sum and average over cached values (dates as serials), with a scan limit.The core entry also gains
resolveColor. §4.4 already documented it, but it wasn't implemented:Tested values include Excel's "Accent 1, Lighter 80%" (
DAE3F3).Measured (docs/api.md §5.8.5; Apple M2, Node 26.13.1,
npm run bench:render)Benchmarksjob runs this script too, and reports to its summary and artifact.In CI (GitHub Actions, Node 24,
Benchmarksjob)Checks
test/render/render.test.tshas 25 Node tests: geometry and hit testing, extent and settings, merges, shared styles from a real write→read, fills/fonts/alignment/row-style fallback, the border rule (weight, tie, empty-cell edge, merge neighbours), text/format hook/rich text, formula text, hyperlinks, navigation, TSV/HTML/stats, and resolveColor../renderwith types conditions. tsdown entry, entries test, smoke/consumer expectations (runtime, type fixture, tree-shaking marker), TypeDoc entry, README row./formatcompatibility is now a test, since/formatis on main:const hook: RenderFormatter = formatCelltype-checks. Withlocale: 'de-DE'it renders(1.234,50)in#FF0000for#,##0.00;[Red](#,##0.00), and15.01.2024for id 14.npm test857 passed (main with/importand/formatmerged in), publint, smoke (tsc node16/nodenext/bundler; unused-entry tree-shaking drops/render), docs snippets, and the API reference builds with no warnings.Notes for the viewer design
createRenderSheetacceptsWorkbook<CellInput>(reader output and built workbooks with bare values alike), not onlyWorkbook<Cell>.RenderCellhasedges(the resolved borders it draws) next tostyle.border(its own borders). The viewer design had the resolved edges inside the shared style. They can't be shared per style, because they depend on neighbours.fillis{ char, at }, like/format's, so the UI knows where to repeat the character.No new dependencies.