Skip to content

feat: Excel table option, context param, streaming addObject#168

Merged
productdevbook merged 1 commit intomainfrom
feat/schema-builder-2
Apr 4, 2026
Merged

feat: Excel table option, context param, streaming addObject#168
productdevbook merged 1 commit intomainfrom
feat/schema-builder-2

Conversation

@productdevbook
Copy link
Copy Markdown
Owner

Summary

  • writeObjects table option — auto-generates native Excel table (ListObject) from columns with totals, style, autoFilter
  • writeObjects context param — injects runtime context into column callbacks via item.__ctx
  • XlsxStreamWriter.addObject() — write objects using ColumnDef value accessors (key, dot-path, function)

API Examples

Excel Table (#142)

const xlsx = await writeObjects(data, {
  columns: [
    { key: 'product', header: 'Product' },
    { key: 'revenue', header: 'Revenue', numFmt: '$#,##0' },
  ],
  table: {
    name: 'SalesTable',
    style: 'TableStyleMedium2',
    showTotalRow: true,
    totals: { revenue: 'sum' },
  },
})

Context (#149)

const xlsx = await writeObjects(data, {
  columns: [{
    header: 'Converted',
    value: (item) => item.price * item.__ctx.rate,
  }],
  context: { rate: 0.92 },
})

Streaming addObject (#150)

const writer = new XlsxStreamWriter({
  name: 'Data',
  columns: [
    { value: 'user.name', header: 'Name' },
    { key: 'score', header: 'Score' },
  ],
})
writer.addObject({ user: { name: 'Alice' }, score: 95 })
const xlsx = await writer.finish()

Test plan

  • 2087 tests pass (7 new)
  • TypeScript typecheck clean
  • Lint + format clean

Closes #142, #149, #150

🤖 Generated with Claude Code

- writeObjects table option: auto-generates TableDefinition from
  columns with totals, style, autoFilter (#142)
- writeObjects context param: injects context into column callbacks
  via item.__ctx for runtime data like currency, locale (#149)
- XlsxStreamWriter.addObject(): write objects using ColumnDef
  value accessors (key, dot-path, function) (#150)
- 7 new tests (48 total in schema-builder.test.ts)

Closes #142, closes #149, closes #150

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@productdevbook productdevbook merged commit 7f0b04a into main Apr 4, 2026
1 check 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.

feat: writeObjects with Excel tables — auto-generate TableDefinition from columns

1 participant