(
fileTitle: string,
date: [number, number],
sheetTitle: string,
tableId: string,
tableColumnConfig: (ProColumnType<T> & { eoTitle: string })[],
tableData: T[]
)
| 13 | } |
| 14 | |
| 15 | const exportExcel = async ( |
| 16 | fileTitle: string, |
| 17 | date: [number, number], |
| 18 | sheetTitle: string, |
| 19 | tableId: string, |
| 20 | tableColumnConfig: (ProColumnType<T> & { eoTitle: string })[], |
| 21 | tableData: T[] |
| 22 | ) => { |
| 23 | const workBook = createExcel( |
| 24 | sheetTitle, |
| 25 | getColumns(tableId, tableColumnConfig) as ExcelJS.Column[], |
| 26 | tableData || [] |
| 27 | ) |
| 28 | const fileName = getFileName(fileTitle, date) |
| 29 | try { |
| 30 | const buffer = await workBook.xlsx.writeBuffer() |
| 31 | saveAs( |
| 32 | new Blob([buffer], { |
| 33 | type: 'application/octet-stream' |
| 34 | }), |
| 35 | `${fileName}.xlsx` |
| 36 | ) |
| 37 | } catch (error) { |
| 38 | console.error('Error exporting Excel file:', error) |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | const getColumns = (tableId: string, tableColumnConfig: (ProColumnType<T> & { eoTitle: string })[]) => { |
| 43 | let tableConfig: Record<string, { show: boolean }> | null |
no test coverage detected