Open YBFACC opened 7 months ago
下载
function downloadExcel(workbook: Workbook, fileName: string) {
const buffer = await workbook.xlsx.writeBuffer()
const blob = new Blob([buffer], {
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
})
const a = document.createElement('a')
document.body.appendChild(a)
a.style.display = 'none'
a.download = `${fileName}.xlsx`
const url = URL.createObjectURL(blob)
a.href = url
a.click()
await new Promise<void>(res => {
setTimeout(() => {
try {
document.body.removeChild(a)
} catch (error) {
console.warn(error)
}
window.URL.revokeObjectURL(url)
res()
})
})
}
这里使用 exceljs
特定列设置预设值
sheet.dataValidations.model['A2:A9999'] = { type: 'list', allowBlank: true, formulae: ['"male,female,other"'] };
这里使用 exceljs
特定列设置预设值
sheet.dataValidations.model['A2:A9999'] = { type: 'list', allowBlank: true, formulae: ['"male,female,other"'] };
时间预设
sheet.dataValidations.model[`${convertToTitle(index + 1)}2:${convertToTitle(index + 1)}99999`] = {
type: 'date',
showErrorMessage: true,
allowBlank: true,
formulae: [],
error: '正确例子: 2023/1/1 20:20'
};
这里使用 exceljs
特定列设置预设值