表格导出插件
我们在@visactor/vtable-plugins中封装了表格导出插件,使用该插件可以方便的导出VTable表格为Excel和CSV文件。
插件说明
该插件会向table实例添加exportToCsv和exportToExcel方法。
- exportToCsv:导出CSV文件
- exportToExcel:导出Excel文件
插件配置介绍
插件初始化传入插件配置,配置项如下:
export type TableExportPluginOptions = { exportExcelOptions?: ExportVTableToExcelOptions; // Excel导出配置 exportCsvOptions?: ExportVTableToCsvOptions; // CSV导出配置 exportOnIdle?: boolean; // 是否空闲时导出下载,默认false };
其中exportExcelOptions和exportCsvOptions为导出配置,exportOnIdle为是否空闲时导出下载,默认false。
exportExcelOptions和exportCsvOptions的配置项如下:
export type ExportVTableToExcelOptions = {
ignoreIcon?: boolean;
exportAllData?: boolean;
formatExportOutput?: (cellInfo: CellInfo) => string | undefined;
formatExcelJSCell?: (cellInfo: CellInfo, cellInExcelJS: ExcelJS.Cell) => ExcelJS.Cell;
excelJSWorksheetCallback?: (worksheet: ExcelJS.Worksheet) => void;
skipImageExportCellType?: SkipImageExportCellType[];
downloadFile?: boolean;
fileName?: string;
};
export type ExportVTableToCsvOptions = {
formatExportOutput?: (cellInfo: CellInfo) => string | undefined;
escape?: boolean; // 是否需要将字符串中的特殊符号进行转义,以避免干扰CSV解析,默认为true
exportAllData?: boolean;
downloadFile?: boolean;
fileName?: string;
};