Skip to content

fix(xlsx): preserve outline summary placement in streaming writers - #593

Open
MathiasWP wants to merge 1 commit into
productdevbook:mainfrom
MathiasWP:ws/skudeneshavn-66dd38035d3e4fefba2c3a3dc7cb3d85
Open

MathiasWP wants to merge 1 commit into
productdevbook:mainfrom
MathiasWP:ws/skudeneshavn-66dd38035d3e4fefba2c3a3dc7cb3d85

Conversation

@MathiasWP

@MathiasWP MathiasWP commented Oct 19, 2026 •

Copy link
Copy Markdown

Streaming a parent row followed by an outlined child writes the child's outlineLevel, but omits the sheet-level summary placement. Excel therefore uses summary-below placement even when the caller needs summaries above their children. The buffered writer already supports this setting.

Closes #592.

This adds the existing OutlineProperties option to writeXlsxStream, writeXlsxStreamSheets, and XlsxStreamWriter. The shared worksheet prelude emits sheetPr/outlinePr before sheetViews, preserving explicit summaryBelow and summaryRight values on every rollover sheet. Omitted settings retain their existing behavior, and multi-sheet exports keep each sheet's settings separate.

For example, outlineProperties: { summaryBelow: false } with [["Parent"], ["Child"]] and child row outlineLevel: 1 now emits <sheetPr><outlinePr summaryBelow="0"/></sheetPr> and reads back as summaryBelow: false.

Existing row-outline coverage did not exercise sheet-level summary placement. The new regression tests cover both writer paths, explicit true/false and omitted attributes, XML element ordering, freeze panes, repeated headers, rollover, and per-sheet isolation. 13 of the 15 new tests failed before the fix.

Validation on Bun 1.4.2 and Node.js 26.7.0:

  • bun run test --maxWorkers=2: lint, formatting, both TypeScript configurations, and all 10,713 tests across 241 files passed.
  • bun run verify:package: build and all packaged-artifact checks passed.
  • git diff --check: passed.

The default-worker test run hit an unrelated 20-second timeout in test/html-import.test.ts; reducing workers passed without changing that test or its timeout. Generated worksheet XML and read-back behavior were checked; the workbook was not opened manually in Excel.

Summary by CodeRabbit

  • New Features
    • Streaming XLSX exports now support configuring outline summary placement for each sheet, including whether summaries appear below rows and to the right of columns. Unspecified settings remain unchanged.

@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e7cf2bf9-4ba4-4b23-90d5-dc09cd26e89e
📥 Commits

Reviewing files that changed from the base of the PR and between c991ad0 and 1ff6737.

📒 Files selected for processing: 2
  • src/xlsx/stream-writer.ts
  • test/xlsx-stream-outlines.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

📝 Walkthrough

Streaming XLSX writer options now accept outlineProperties for single-sheet and per-sheet configuration. The writers serialize defined summary-placement values in worksheet properties. Tests cover both writer APIs, rollover sheets, and independent outline settings.

Changes: Streaming XLSX Outline Properties

Layer / File(s) Summary
Outline options and worksheet serialization
src/xlsx/stream-writer.ts
Streaming options now include outlineProperties. The shared sheet prelude emits sheetPr and outlinePr before sheet views, and writes each defined placement value as 1 or 0.
Writer integration and coverage
src/xlsx/stream-writer.ts, test/xlsx-stream-outlines.test.ts
The incremental writer, single-sheet streaming API, and per-sheet streaming API pass outline properties to the prelude builder. Tests check omitted properties, rollover sheets, freeze panes, element order, and independent settings across sheets.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Bug fix · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant writeXlsxStream
  participant writeXlsxStreamSheets
  participant XlsxStreamWriter
  participant buildSheetPrelude
  participant WorksheetXML
  Caller->>writeXlsxStream: Pass outlineProperties
  writeXlsxStream->>writeXlsxStreamSheets: Forward single-sheet configuration
  writeXlsxStreamSheets->>buildSheetPrelude: Pass sheet outlineProperties
  buildSheetPrelude->>WorksheetXML: Emit sheetPr and outlinePr
  Caller->>XlsxStreamWriter: Set outlineProperties
  XlsxStreamWriter->>buildSheetPrelude: Pass stored outlineProperties
Loading

Suggested reviewers: productdevbook

Merge Risk: ⚪ Minimal · up to 1ff67

The outline-property change is ready for normal merge checks; no current merge-blocking risk was identified.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: preserving outline summary placement in streaming XLSX writers.
Linked Issues check Passed Issue #592 requires streaming options to expose and serialize outlineProperties, including summaryBelow and summaryRight, before sheetViews, with values preserved on rollover and omitted setti…
Out of Scope Changes check Passed The changes stay within issue #592. The source changes add the requested public option, shared worksheet serialization, and propagation through the streaming writer paths. The new tests verify the req…
Full details: Linked Issues check

Explanation

Issue #592 requires streaming options to expose and serialize outlineProperties, including summaryBelow and summaryRight, before sheetViews, with values preserved on rollover and omitted settings retaining defaults. The diff adds outlineProperties to StreamWriterOptions and XlsxStreamSheet. buildSheetPrelude emits sheetPr/outlinePr before sheetViews and serializes each defined property as 1 or 0. The option reaches writeXlsxStream, writeXlsxStreamSheets, and XlsxStreamWriter, including rollover sheets. The new tests cover both writer paths, rollover, omitted attributes, default behavior, and per-sheet isolation.

Full details: Out of Scope Changes check

Explanation

The changes stay within issue #592. The source changes add the requested public option, shared worksheet serialization, and propagation through the streaming writer paths. The new tests verify the requested XML, read-back behavior, ordering, rollover behavior, and sheet isolation. The documentation comment describes the same per-sheet behavior. No unrelated product behavior is shown.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

This branch has not been deployed

No deployments
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.

XLSX streaming writers cannot place outline summaries above child rows

1 participant