Architecture decision record · ADR-0014

Export and charts (milestone M8)

One model for all writers. ExportSheet holds the leaf columns, the header group rows, the rows in display order with a group level, and an optional totals row.

Status
Proposed
Deciders
Joe Gaudet
Created
Updated
PRD
PRD
Related
None

Context

Decision 27 puts export and charts in 1.0. Plan section 8.5 makes IronCalc the first choice for XLSX, and asks for CSV for all surfaces. Spike S9 asks for a PDF writer without a heavy dependency: pdf-lib (MIT), loaded on demand. ADR 0006 loads @ironcalc/wasm-xlsx only for import and export, because only that build has toXlsx and fromXlsx. @ironcalc/wasm 0.9.1 does not have them.

Decision drivers

Not recorded in the original ADR.

Options considered

Not recorded in the original ADR.

Decision

  1. One model for all writers. ExportSheet holds the leaf columns, the header group rows, the rows in display order with a group level, and an optional totals row. Each cell has a value and the text that the grid shows. fromTable makes the model from a table through a structural type, so @ember-lattice/export imports nothing from core or Ember.
  2. CSV follows RFC 4180, and is safe by default. The safe option puts ' before text that starts with =, +, -, @, a tab or a CR (CSV injection). Number cells do not change.
  3. XLSX: the app gives the IronCalc module. toXlsx(sheet, ironcalc) takes the loaded @ironcalc/wasm-xlsx module. The export package does not bundle or load the 2.5 MB engine. Text cells start with ' in setUserInput, so IronCalc keeps them as text.
  4. PDF uses the standard fonts. toPdf loads pdf-lib with a dynamic import. The header rows repeat on each page. A table that is wider than the page shrinks in proportion.
  5. Sparklines are plain SVG. They do not use @ember-joinery/chart, because a grid can show 1,000 of them. Each has role="img" and a label with the minimum, the maximum and the last value.
  6. LatticeChart uses @ember-joinery/chart. It reads the current rows of the table, or a range of row ids.

Consequences

Limits

  • XLSX: IronCalc 0.9.1 has no row outline API. Group rows are bold, but the file does not keep the group levels. The writer uses the en locale and UTC.
  • XLSX: the IronCalc column width unit is the pixel. The writer gives the grid width.
  • PDF: the standard Helvetica font has WinAnsi letters only. Other letters become ?. A Unicode font needs @pdf-lib/fontkit and an embedded font file.
  • PDF: a column that is too narrow for one letter and an ellipsis shows no text.
  • fromTable with visibleOnly: false gives no header group rows.

Confirmation

Evidence

  • Vitest, packages/export/tests: 15 tests. CSV (5, with a fast-check round trip), fromTable (4), XLSX (3, read back with fromXlsx), PDF (3, read back with pdf-lib).
  • QUnit, test-app/tests/charts (filter Charts): 9 tests, each with an axe audit. They include a real grouped table with a sum aggregation into fromTable, and download in Chrome.
  • 1,000 line sparklines of 20 points: 72 ms to render and lay out (Chrome 158, Apple M4).

Interview record

Each question of the interview with its answer and its source. A fact from the code or a document, a question that the author did not ask, and an assumption are rows too.

QuestionAnswerSource
Where does the text of this page come from?From the Markdown file docs/adr/0014-export-and-charts.md at commit 4c77ac4. The text of each section is the text of the Markdown file. A section that the Markdown file does not have says so.Document: docs/adr/0014-export-and-charts.md

Changelog

DateAuthorChange
2026-12-01Joe GaudetStatus in the Markdown file: proposed, 2026-12-01.
2026-12-03Joe GaudetCommit 7ce4af2: Lattice 1.0 (#1)
2026-12-04Joe Gaudet (agent)Converted from docs/adr/0014-export-and-charts.md to this page. The text is the text of the Markdown file.

The adr skill of skillsaw wrote this page. The HTML in this file is the source of truth. The diagrams are the Mermaid sources in it.