// 下载模板
downloadex() {
const data = [['标题1', '标题2', ]];
let list = []
data[0].forEach(() => {
list.push('');
})
for (let a = 0; a < 10000; a++) {
data.push(list);
}
// 创建工作簿对象
const wb = XLSX.utils.book_new();
// 创建工作表对象
const ws = XLSX.utils.aoa_to_sheet(data);
data.forEach((row, rowIndex) => { //设置所有单元格的格式为文本
row.forEach((cellValue, colIndex) => {
const cellAddress = XLSX.utils.encode_cell({ r: rowIndex + 1, c: colIndex }); // 单元格地址(例如 "A1")
if (!ws[cellAddress]) {
ws[cellAddress] = {}; // 如果单元格不存在,则创建它
}
ws[cellAddress].z = 'm'; // 设置单元格格式为文本
ws[cellAddress].z = '@'; // 设置单元格格式为文本,数字也是按照字符串处理
});
});
// 添加工作表到工作簿
XLSX.utils.book_append_sheet(wb, ws, 'Sheet1');
// 导出为 Excel 文件
XLSX.writeFile(wb, 'xxxx.xlsx');
},
03-15
5688

06-07
1963
