MCPcopy Create free account
hub / github.com/APIParkLab/APIPark / exportExcel

Function exportExcel

frontend/packages/common/src/hooks/excel.ts:15–40  ·  view source on GitHub ↗
(
    fileTitle: string,
    date: [number, number],
    sheetTitle: string,
    tableId: string,
    tableColumnConfig: (ProColumnType<T> & { eoTitle: string })[],
    tableData: T[]
  )

Source from the content-addressed store, hash-verified

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

Callers 3

exportDataFunction · 0.85
exportDataFunction · 0.85
exportDataFunction · 0.85

Calls 3

createExcelFunction · 0.85
getColumnsFunction · 0.85
getFileNameFunction · 0.85

Tested by

no test coverage detected