Skip to content

ExportPlugin

Export Plugin for tbw-grid

Lets users download grid data as CSV, Excel (XML), or JSON with a single click or API call. Great for reporting, data backup, or letting users work with data in Excel. Integrates with SelectionPlugin to export only selected rows.

import { ExportPlugin } from '@toolbox-web/grid/plugins/export';
OptionTypeDefaultDescription
fileNamestring'export'Base filename (without extension)
includeHeadersbooleantrueInclude column headers in export
onlyVisiblebooleantrueExport only visible columns
onlySelectedbooleanfalseExport only selected rows (requires SelectionPlugin)
FormatMethodDescription
CSVexportToCSV()Comma-separated values
ExcelexportToExcel()Excel XML format (.xlsx)
JSONexportToJSON()JSON array of objects
MethodSignatureDescription
exportToCSV(params?) => voidExport as CSV file
exportToExcel(params?) => voidExport as Excel file
exportToJSON(params?) => voidExport as JSON file
isExporting() => booleanCheck if export is in progress
import { queryGrid } from '@toolbox-web/grid';
import { ExportPlugin } from '@toolbox-web/grid/plugins/export';
const grid = queryGrid('tbw-grid');
grid.gridConfig = {
columns: [
{ field: 'name', header: 'Name' },
{ field: 'email', header: 'Email' },
],
plugins: [new ExportPlugin({ fileName: 'employees', includeHeaders: true })],
};
// Trigger export via button
document.getElementById('export-btn').addEventListener('click', () => {
grid.getPluginByName('export').exportToCSV();
});
import { SelectionPlugin } from '@toolbox-web/grid/plugins/selection';
grid.gridConfig = {
plugins: [
new SelectionPlugin({ mode: 'row' }),
new ExportPlugin({ onlySelected: true }),
],
};

Extends BaseGridPlugin

Inherited methods like attach(), detach(), afterRender(), etc. are documented in the base class.

Export data to CSV format.

exportCsv(params: Partial<ExportParams>): void
NameTypeDescription
paramsPartial<ExportParams>Optional export parameters

Export data to Excel format (XML Spreadsheet).

exportExcel(params: Partial<ExportParams>): void
NameTypeDescription
paramsPartial<ExportParams>Optional export parameters

Export data to JSON format.

exportJson(params: Partial<ExportParams>): void
NameTypeDescription
paramsPartial<ExportParams>Optional export parameters

Check if an export is currently in progress.

isExporting(): boolean

boolean - Whether export is in progress


Get information about the last export.

getLastExport(): object | null

object | null - Export info or null if no export has occurred


AI assistants: For complete API documentation, implementation guides, and code examples for this library, see https://raw.githubusercontent.com/OysteinAmundsen/toolbox/main/llms-full.txt