How to use the dash-table/components/Table/props.ExportFormat.Xlsx function in dash-table

To help you get started, we’ve selected a few dash-table examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github plotly / dash-table / tests / visual / percy-storybook / DashTable.percy.tsx View on Github external
.add('Export Button for xlsx file', () => ())
    .add('Export Button for csv file', () => (
github plotly / dash-table / src / dash-table / components / Export / index.tsx View on Github external
export default React.memo((props: IExportButtonProps) => {

    const { columns, export_columns, export_format, virtual_data, export_headers, visibleColumns, merge_duplicate_headers } = props;
    const isFormatSupported = export_format === ExportFormat.Csv || export_format === ExportFormat.Xlsx;

    const exportedColumns = export_columns === ExportColumns.Visible ? visibleColumns : columns;

    const handleExport = async () => {
        const columnID = exportedColumns.map(column => column.id);
        const columnHeaders = exportedColumns.map(column => column.name);

        const maxLength = getHeaderRows(columns);
        const heading = (export_headers !== ExportHeaders.None) ? createHeadings(columnHeaders, maxLength) : [];

        const wb = await createWorkbook(heading, virtual_data.data, columnID, export_headers, merge_duplicate_headers);

        await exportWorkbook(wb, export_format);
    };

    return (<div></div>
github plotly / dash-table / src / dash-table / dash / Sanitizer.ts View on Github external
sanitize(props: PropsWithDefaults): SanitizedProps {
        const locale_format = this.applyDefaultToLocale(props.locale_format);
        const columns = this.applyDefaultsToColumns(locale_format, props.sort_as_null, props.columns, props.editable);
        const visibleColumns = this.getVisibleColumns(columns, props.hidden_columns);

        let headerFormat = props.export_headers;
        if (props.export_format === ExportFormat.Xlsx && R.isNil(headerFormat)) {
            headerFormat = ExportHeaders.Names;
        } else if (props.export_format === ExportFormat.Csv && R.isNil(headerFormat)) {
            headerFormat = ExportHeaders.Ids;
        }

        return R.merge(props, {
            columns,
            export_headers: headerFormat,
            fixed_columns: getFixedColumns(props.fixed_columns, props.row_deletable, props.row_selectable),
            fixed_rows: getFixedRows(props.fixed_rows, props.columns, props.filter_action),
            loading_state: dataLoading(props.loading_state),
            locale_format,
            visibleColumns
        });
    }