Initial commit

This commit is contained in:
meswork
2026-06-01 17:55:16 +08:00
commit 9cfb8d16f0
33 changed files with 27762 additions and 0 deletions

35
src/utils/excelWriter.js Normal file
View File

@@ -0,0 +1,35 @@
import XLSX from 'xlsx'
import { buildWorkbookSheets } from './signalTableBuilder'
import { saveBlob } from './filePicker'
export function createSignalTableWorkbook(data) {
const workbook = XLSX.utils.book_new()
buildWorkbookSheets(data).forEach(sheet => {
const worksheet = XLSX.utils.aoa_to_sheet(sheet.rows)
worksheet['!cols'] = (sheet.cols || []).map(wch => ({ wch }))
XLSX.utils.book_append_sheet(workbook, worksheet, sheet.name)
})
return workbook
}
export async function exportSignalTable(data, filename = 'SignalTable_CZ.xlsx') {
const workbook = createSignalTableWorkbook(data)
const content = XLSX.write(workbook, {
bookType: 'xlsx',
type: 'array'
})
const blob = new Blob([content], {
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
})
return saveBlob(blob, filename, [
{
description: 'Excel 工作簿',
accept: {
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': ['.xlsx']
}
}
])
}