Skip to content

Examples

All examples generate .xlsx files in examples/output/.

The screenshots on this page come from examples/expected/ and make the feature set easier to scan before you run anything locally.

Terminal window
bun run examples

Run individual examples:

Terminal window
bun run example:basic
bun run example:styling
bun run example:dynamic
bun run example:processors
bun run example:merged
bun run example:templates
bun run example:images
bun run example:complex-merge

01. Basic workbook structure

Basic workbook output

  • Shows the minimum viable workbook: Workbook, Worksheet, Column, Row, and Cell
  • Good first reference for column widths and plain value rendering
  • Source: examples/01-basic.tsx
  • Docs: Workbook, Worksheet, Cell

02. Styling with className

Styling example output

  • Shows shared header styling, row styling, borders, alignment, and formatted totals
  • Demonstrates how Group lets you apply styling to several cells at once
  • Source: examples/02-styling.tsx
  • Docs: Styling, Properties, Group

03. Dynamic rows, formats, formulas, and named ranges

Dynamic data output

  • Maps data arrays directly into rows
  • Uses column-level date and currency formatting
  • Demonstrates named column ranges with id and formulas like SUM(Salaries)
  • Source: examples/03-dynamic-data.tsx
  • Docs: Format, Formula, Column

04. Processors and conditional styling

Processors example output

  • Shows row processors applying zebra striping during render
  • Combines processors with value-based styling for status cells
  • Good reference for reusable render-time transformations
  • Source: examples/04-processors.tsx
  • Docs: Processors, Group

05. Merged cells and report layouts

Merged cells example output

  • Demonstrates colSpan and rowSpan in practical reporting layouts
  • Shows section headers, vertically merged category labels, and merged summary blocks
  • Source: examples/05-merged-cells.tsx
  • Docs: Merges, Cell

06. Templates and post-template content

Template example output

  • Loads an .xlsx template, expands the data row, then appends new JSX content below it
  • Useful for invoice and branded document workflows
  • Note: current template expansion targets row-based placeholders; non-row placeholders visible in the screenshot remain unchanged
  • Source: examples/06-templates.tsx
  • Docs: Templates, Template

07. Worksheet and cell-level images

Images example output

  • Embeds images from both base64 strings and files
  • Demonstrates cell-child images with explicit positioning and sizing
  • Source: examples/07-images.tsx
  • Docs: Images, Image

08. Advanced merge stress test

Complex merge output

  • Stresses mixed rowSpan and colSpan combinations in a single grid
  • Helpful for validating dashboards, matrix layouts, and nested merge blocks
  • Source: examples/08-complex-merge.tsx
  • Docs: Merges, Cell

Best examples by feature

  • className styling: examples/02-styling.tsx
  • dynamic data + formulas: examples/03-dynamic-data.tsx
  • processors: examples/04-processors.tsx
  • practical merges: examples/05-merged-cells.tsx
  • template-driven output: examples/06-templates.tsx
  • image embedding: examples/07-images.tsx
  • complex merge edge cases: examples/08-complex-merge.tsx