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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@bw-ui/datatable-export

v1.0.2

Published

Export plugin for @bw-ui/datatable - JSON, CSV, Clipboard

Downloads

313

Readme

@bw-ui/datatable-export

CSV and JSON export plugin for BWDataTable.

Features

  • 📄 CSV Export - Download as comma-separated values
  • 📋 JSON Export - Download as JSON array
  • 🎯 Selective Export - Export all or selected rows only
  • 📝 Custom Filenames - Configurable output filename
  • Instant Download - Client-side file generation

Installation

npm install @bw-ui/datatable-export

Usage

import { BWDataTable } from '@bw-ui/datatable';
import { ExportPlugin } from '@bw-ui/datatable-export';

const table = new BWDataTable('#table', { data }).use(ExportPlugin, {
  filename: 'my-data', // Default filename (default: 'export')
  includeHeaders: true, // Include headers in CSV (default: true)
});

// Export all data to CSV
table.exportCSV();

// Export with custom filename
table.exportCSV('users-report');

// Export only selected rows
table.exportCSV('selected-users', true);

// Export to JSON
table.exportJSON('data-backup');

// Export selected to JSON
table.exportJSON('selected', true);

Options

| Option | Type | Default | Description | | ---------------- | --------- | ---------- | ------------------------------------ | | filename | string | 'export' | Default filename (without extension) | | includeHeaders | boolean | true | Include column headers in CSV |

API

Methods (added to table)

// Export to CSV
table.exportCSV(); // export.csv
table.exportCSV('users'); // users.csv
table.exportCSV('users', true); // Selected rows only
table.exportCSV('users', false); // All rows

// Export to JSON
table.exportJSON(); // export.json
table.exportJSON('data'); // data.json
table.exportJSON('data', true); // Selected rows only
table.exportJSON('data', false); // All rows

Events

// After export complete
table.on('export:complete', ({ format, filename, count }) => {
  console.log(`Exported ${count} rows to ${filename}.${format}`);
});

Output Formats

CSV Format

Id,Name,Email,Salary
1,John,[email protected],50000
2,Jane,[email protected],60000
  • Comma-separated values
  • First row contains headers (if enabled)
  • Values with commas/quotes are properly escaped
  • Compatible with Excel, Google Sheets, etc.

JSON Format

[
  {
    "id": 1,
    "name": "John",
    "email": "[email protected]",
    "salary": 50000
  },
  {
    "id": 2,
    "name": "Jane",
    "email": "[email protected]",
    "salary": 60000
  }
]
  • Array of objects
  • Pretty-printed for readability
  • All data types preserved

Example: Export Buttons

<button id="exportCSV">Export CSV</button>
<button id="exportJSON">Export JSON</button>
<button id="exportSelected">Export Selected</button>
const table = new BWDataTable('#table', { data }).use(ExportPlugin);

document.getElementById('exportCSV').addEventListener('click', () => {
  table.exportCSV('users');
});

document.getElementById('exportJSON').addEventListener('click', () => {
  table.exportJSON('users');
});

document.getElementById('exportSelected').addEventListener('click', () => {
  const selected = table.getSelected();
  if (selected.length === 0) {
    alert('Select some rows first');
    return;
  }
  table.exportCSV('selected-users', true);
});

Example: With Date in Filename

const table = new BWDataTable('#table', { data }).use(ExportPlugin);

function exportWithDate() {
  const date = new Date().toISOString().split('T')[0];
  table.exportCSV(`users-${date}`);
  // Downloads: users-2024-01-15.csv
}

TypeScript

import { BWDataTable } from '@bw-ui/datatable';
import { ExportPlugin, ExportPluginOptions } from '@bw-ui/datatable-export';

const options: ExportPluginOptions = {
  filename: 'report',
  includeHeaders: true,
};

const table = new BWDataTable('#table', { data }).use(ExportPlugin, options);

table.on('export:complete', ({ format, filename, count }) => {
  // Typed event data
});

Notes

  • Exports are generated client-side (no server required)
  • Large exports may take a moment to generate
  • File downloads via browser's native download mechanism
  • Respects current filter (exports filtered data)

License

MIT © BW UI