npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@topgrid/grid-export

v0.6.0

Published

Excel, PDF, CSV export for grid data

Readme

@topgrid/grid-export

Excel, PDF, CSV export for grid data

Installation

pnpm add @topgrid/grid-export
# or
npm install @topgrid/grid-export
# or
yarn add @topgrid/grid-export

Peer Dependencies

| Package | Version | Required | |---------|---------|---------| | @tanstack/react-table | ^8.0.0 | Yes | | react | ^18.0.0 \|\| ^19.0.0 | Yes | | react-dom | ^18.0.0 \|\| ^19.0.0 | Yes | | xlsx | ^0.18.5 | Yes | | jspdf | ^2.5.0 | Optional (PDF only) | | jspdf-autotable | ^3.5.0 | Optional (PDF only) |

Usage

Excel Export (TanStack Table)

import { exportToExcel } from '@topgrid/grid-export';

// Export all visible rows to Excel
exportToExcel(table, {
  fileName: 'my-data.xlsx',
  sheetName: 'Sheet1',
});

Excel Export (Row Array — ADR-005)

Use when you have raw row data without a TanStack Table instance.

import { exportRowsToExcel, type ExcelColumn } from '@topgrid/grid-export';

const columns: ExcelColumn[] = [
  { key: 'name', header: '이름', width: 20 },
  { key: 'score', header: '점수', width: 10, format: 'number' },
  { key: 'date', header: '날짜', width: 15, format: 'date' },
];

exportRowsToExcel(rows, columns, {
  fileName: '보고서_2026.xlsx',
  sheetName: 'Sheet1',
  // emptyBehavior: 'empty' — emit header-only file when rows is empty (default: 'skip')
});

Excel — Native Number Formats & Column Widths

Apply native Excel number-format codes (.z) per column. Cells stay numeric and sortable inside Excel (unlike pre-formatting values to strings). Optionally set column widths.

import { exportToExcel } from '@topgrid/grid-export';

exportToExcel(table, {
  fileName: 'sales.xlsx',
  columnFormats: {
    price: '#,##0.00',     // 1,234.50
    rate: '0.0%',          // 12.3%
    orderedAt: 'yyyy-mm-dd', // applies only if the cell value is a Date / number
  },
  columnWidths: { name: 30, memo: 40 },
});

Number formats apply to numeric cells only. A format code is set on a cell only when its value is a number (and Date values, which Excel stores as numeric serials — so 'yyyy-mm-dd' formats a Date but not an ISO date string). String cells pass through unchanged: a format on a text value would be a no-op, so it is skipped rather than silently stored. Format string-typed dates upstream, or provide Date/number values.

Cell styling limitation (font / background): the xlsx community edition (^0.18.5) does not persist cell styles (.s — font, fill/background, borders) on write — they are silently dropped from the output file. grid-export therefore exposes only what survives a real write→read round-trip: number formats (.z) and column widths (!cols). It does not claim font/background support. For styled cells, a styling-capable writer (e.g. a Pro xlsx build) is required.

Excel — Multiple Sheets

Export several tables into one workbook, one sheet each. Each sheet reuses the same header-merge / scope / number-format behavior as single-sheet exportToExcel.

import { exportSheetsToExcel, type ExcelSheet } from '@topgrid/grid-export';

const sheets: ExcelSheet[] = [
  { name: '주문', table: ordersTable, columnFormats: { total: '#,##0' } },
  { name: '고객', table: customersTable, scope: 'selected' },
];

exportSheetsToExcel(sheets, { fileName: '월간보고.xlsx' });

CSV Export

import { exportToCSV } from '@topgrid/grid-export';

exportToCSV(table, {
  fileName: 'my-data.csv',
  delimiter: ',',
});

PDF Export

import { exportToPdf } from '@topgrid/grid-export';

exportToPdf(table, {
  fileName: 'my-data.pdf',
  title: 'My Grid Report',
});

Clipboard & Print

import { copyToClipboard, printGrid } from '@topgrid/grid-export';

// Copy selected data to clipboard (header row included by default)
copyToClipboard(table);

// Copy data rows only (no header) — useful when pasting under existing headers
copyToClipboard(table, { includeHeader: false });

// Print the grid
printGrid(table, { title: 'Report' });

Main API

| Export | Description | |--------|-------------| | exportToExcel | Export grid data to Excel (.xlsx) — TanStack Table<TData> based. Supports native number formats (columnFormats) + column widths | | exportSheetsToExcel | Export multiple tables into one multi-sheet workbook (.xlsx) | | exportRowsToExcel | Export row array to Excel (.xlsx) — raw TData[] + ExcelColumn[] based (ADR-005) | | exportToCSV | Export grid data to CSV | | exportToPdf | Export grid data to PDF | | copyToClipboard | Copy grid data to clipboard | | printGrid | Print grid content |

License

MIT


Documentation | API Reference