Skip to main content

exportData

Use the exportData helper to generate csv and xls files without VirtualTable

import React from 'react'; 

import { exportData } from '@myunisoft/design-system'

const ExportButtonCSV = ({ data, columns }) => {
return (
<button
onClick={() => exportData(data, columns, 'csv', 'my_filename')}
>Export to CSV</button>
)
}

export default ExportButtonCSV;

Arguments

Here are the arguments to pass to the helper.

exportData(rows, columns, format, filename, tableRefs, options)

rows

The rows argument is an array of Row object. It's corresponding to the data property of the VirtualTable.

interface Row {
[key: string]: string|number|boolean|null;
}

columns

The columns argument is an array of Column object. It's a light version of the config.columns property of the VirtualTable.

interface Column {
header: string;
key: string;
renderExport?: string|number|(() => string|number);
typeCell?: string
}

format

The values pdf and print are used for the VirtualTable. Avoid using it for the moment.

type ExportFormat = 'csv' | 'xls' | 'pdf' | 'print'

tableRefs

The tableRefs is used for the VirtualTable. Avoid using it for the moment.

options

interface ExportOptions {
delimiter?: ','|';';
rowsFilter?: (Row) => boolean;
}