xlsx
@noy-db/as-xlsx·pnpm add @noy-db/as-xlsx @noy-db/as-zip @noy-db/hubDecrypts records and produces a real.xlsx(Office Open XML) — one sheet per collection. The workbook is plaintext: it leaves noy-db's encryption behind.
What it does
as-xlsx writes a workbook that opens natively in Excel, Numbers,
LibreOffice Calc, and Google Sheets — one sheet per collection, with
dictionary labels resolved instead of stable keys and Unicode-safe
strings routed through the shared-strings table. No heavyweight
spreadsheet library: the only third-party runtime dependency is
fast-xml-parser, alongside @noy-db/as-zip's zip writer. The symmetric
fromBytes() reader inverts human-readable dictionary labels back to
their stable keys before building the import plan — supply a dicts
option explicitly, or populate vault dictionaries with withI18n() for
the automatic path. Pure data export: styles, formulas, merged cells, and
charts are out of scope.
Usage
import { toBytes } from '@noy-db/as-xlsx'
const bytes = await toBytes(vault, {
sheets: [
{ name: 'Invoices', collection: 'invoices', filter: (r) => r.status !== 'draft' },
{ name: 'Payments', collection: 'payments' },
],
})
// → Uint8Array — a complete .xlsx workbook
import { fromBytes } from '@noy-db/as-xlsx'
const plan = await fromBytes(vault, xlsx, { collection: 'invoices' })
// → plan rows carry stable keys ('paid'/'draft'), inverted from dict labels
await plan.apply()
See also
- as-* family
- csv — flat, single-sheet alternative
- zip — the zip writer
as-xlsxbuilds on