xlsx.js 导出代码生成器:根据 HTML 代码生成 Excel 文件
const XLSX = require('xlsx');
const data = [ ['', '', '', '', ''], ['', '', '', '', ''], ['接受药房:', '', '', '', ''], ['接收地址:', '', '', '', ''], ['配送单号:', '', '', '装箱时间:', ''], ['接收时间:', '', '', '接收温度:', ''], ['指定药师:', '', '', '配送人:', ''], ['配送药品明细:', '', '', '', ''], ['药品名称', '药品规格', '药品批号', '有效期', '数量'], ['康可期/阿可替尼胶囊', '', '', '', ''], ['', '', '', '数量合计', ''], ['药房签收:', '', '', '', ''], ['确认包装完整:', '', '', '', ''], ['其他情况备注', '', '', '', ''], ['接收人签字:', '', '', '盖 章 :', ''], ];
const ws = XLSX.utils.aoa_to_sheet(data);
ws['A1'].s = { font: { sz: 14, bold: true, color: { rgb: '000000' }, name: 'SimHei' }, alignment: { horizontal: 'center', vertical: 'middle' }, border: { top: { style: 'thin', color: { rgb: '000000' } }, bottom: { style: 'thin', color: { rgb: '000000' } } }, fill: { bgColor: { indexed: 64 }, fgColor: { rgb: 'FFFFFF' } }, };
ws['A2'].s = { font: { sz: 14, bold: true, color: { rgb: '000000' }, name: 'SimHei' }, alignment: { horizontal: 'center', vertical: 'middle' }, border: { top: { style: 'thin', color: { rgb: '000000' } }, bottom: { style: 'thin', color: { rgb: '000000' } } }, fill: { bgColor: { indexed: 64 }, fgColor: { rgb: 'FFFFFF' } }, };
ws['A3'].s = { font: { sz: 11, color: { rgb: '000000' }, name: 'Arial' }, alignment: { horizontal: 'left', vertical: 'top' }, border: { top: { style: 'thin', color: { rgb: '000000' } }, right: { style: 'thin', color: { rgb: '000000' } }, bottom: { style: 'thin', color: { rgb: '000000' } }, left: { style: 'thin', color: { rgb: '000000' } } }, };
ws['A4'].s = { font: { sz: 11, color: { rgb: '000000' }, name: 'Arial' }, alignment: { horizontal: 'left', vertical: 'top' }, border: { top: { style: 'thin', color: { rgb: '000000' } }, right: { style: 'thin', color: { rgb: '000000' } }, bottom: { style: 'thin', color: { rgb: '000000' } }, left: { style: 'thin', color: { rgb: '000000' } } }, };
ws['A5'].s = { font: { sz: 11, color: { rgb: '000000' }, name: 'Arial' }, alignment: { horizontal: 'left', vertical: 'top' }, border: { top: { style: 'thin', color: { rgb: '000000' } }, right: { style: 'thin', color: { rgb: '000000' } }, bottom: { style: 'thin', color: { rgb: '000000' } }, left: { style: 'thin', color: { rgb: '000000' } } }, };
ws['A6'].s = { font: { sz: 11, color: { rgb: '000000' }, name: 'Arial' }, alignment: { horizontal: 'left', vertical: 'top' }, border: { top: { style: 'thin', color: { rgb: '000000' } }, right: { style: 'thin', color: { rgb: '000000' } }, bottom: { style: 'thin', color: { rgb: '000000' } }, left: { style: 'thin', color: { rgb: '000000' } } }, };
ws['A7'].s = { font: { sz: 11, color: { rgb: '000000' }, name: 'Arial' }, alignment: { horizontal: 'left', vertical: 'top' }, border: { top: { style: 'thin', color: { rgb: '000000' } }, right: { style: 'thin', color: { rgb: '000000' } }, bottom: { style: 'thin', color: { rgb: '000000' } }, left: { style: 'thin', color: { rgb: '000000' } } }, };
ws['A8'].s = { font: { sz: 11, color: { rgb: '000000' }, name: 'Arial' }, alignment: { horizontal: 'left', vertical: 'top' }, border: { top: { style: 'thin', color: { rgb: '000000' } }, right: { style: 'thin', color: { rgb: '000000' } }, bottom: { style: 'thin', color: { rgb: '000000' } }, left: { style: 'thin', color: { rgb: '000000' } } }, };
ws['A9'].s = { font: { sz: 9, color: { rgb: '000000' }, name: 'SimSun' }, alignment: { horizontal: 'left', vertical: 'top' }, border: { top: { style: 'thin', color: { rgb: '000000' } }, right: { style: 'thin', color: { rgb: '000000' } }, bottom: { style: 'thin', color: { rgb: '000000' } }, left: { style: 'thin', color: { rgb: '000000' } } }, };
ws['B9'].s = { font: { sz: 9, color: { rgb: '000000' }, name: 'SimSun' }, alignment: { horizontal: 'left', vertical: 'top' }, border: { top: { style: 'thin', color: { rgb: '000000' } }, right: { style: 'thin', color: { rgb: '000000' } }, bottom: { style: 'thin', color: { rgb: '000000' } }, left: { style: 'thin', color: { rgb: '000000' } } }, };
ws['C9'].s = { font: { sz: 9, color: { rgb: '000000' }, name: 'SimSun' }, alignment: { horizontal: 'left', vertical: 'top' }, border: { top: { style: 'thin', color: { rgb: '000000' } }, right: { style: 'thin', color: { rgb: '000000' } }, bottom: { style: 'thin', color: { rgb: '000000' } }, left: { style: 'thin', color: { rgb: '000000' } } }, };
ws['D9'].s = { font: { sz: 9, color: { rgb: '000000' }, name: 'SimSun' }, alignment: { horizontal: 'left', vertical: 'top' }, border: { top: { style: 'thin', color: { rgb: '000000' } }, right: { style: 'thin', color: { rgb: '000000' } }, bottom: { style: 'thin', color: { rgb: '000000' } }, left: { style: 'thin', color: { rgb: '000000' } } }, };
ws['E9'].s = { font: { sz: 9, color: { rgb: '000000' }, name: 'SimSun' }, alignment: { horizontal: 'left', vertical: 'top' }, border: { top: { style: 'thin', color: { rgb: '000000' } }, right: { style: 'thin', color: { rgb: '000000' } }, bottom: { style: 'thin', color: { rgb: '000000' } }, left: { style: 'thin', color: { rgb: '000000' } } }, };
ws['A10'].s = { font: { sz: 9, color: { rgb: '000000' }, name: 'SimSun' }, alignment: { horizontal: 'left', vertical: 'top' }, border: { top: { style: 'thin', color: { rgb: '000000' } }, right: { style: 'thin', color: { rgb: '000000' } }, bottom: { style: 'thin', color: { rgb: '000000' } }, left: { style: 'thin', color: { rgb: '000000' } } }, };
ws['A11'].s = { font: { sz: 9, color: { rgb: '000000' }, name: 'SimSun' }, alignment: { horizontal: 'left', vertical: 'top' }, border: { top: { style: 'thin', color: { rgb: '000000' } }, right: { style: 'thin', color: { rgb: '000000' } }, bottom: { style: 'thin', color: { rgb: '000000' } }, left: { style: 'thin', color: { rgb: '000000' } } }, };
ws['A12'].s = { font: { sz: 9, color: { rgb: '000000' }, name: 'SimSun' }, alignment: { horizontal: 'left', vertical: 'top' }, border: { top: { style: 'thin', color: { rgb: '000000' } }, right: { style: 'thin', color: { rgb: '000000' } }, bottom: { style: 'thin', color: { rgb: '000000' } }, left: { style: 'thin', color: { rgb: '000000' } } }, };
ws['A13'].s = { font: { sz: 9, color: { rgb: '000000' }, name: 'SimSun' }, alignment: { horizontal: 'left', vertical: 'top' }, border: { top: { style: 'thin', color: { rgb: '000000' } }, right: { style: 'thin', color: { rgb: '000000' } }, bottom: { style: 'thin', color: { rgb: '000000' } }, left: { style: 'thin', color: { rgb: '000000' } } }, };
ws['A14'].s = { font: { sz: 9, color: { rgb: '000000' }, name: 'SimSun' }, alignment: { horizontal: 'left', vertical: 'top' }, border: { top: { style: 'thin', color: { rgb: '000000' } }, right: { style: 'thin', color: { rgb: '000000' } }, bottom: { style: 'thin', color: { rgb: '000000' } }, left: { style: 'thin', color: { rgb: '000000' } } }, };
ws['A15'].s = { font: { sz: 9, color: { rgb: '000000' }, name: 'SimSun' }, alignment: { horizontal: 'left', vertical: 'top' }, border: { top: { style: 'thin', color: { rgb: '000000' } }, right: { style: 'thin', color: { rgb: '000000' } }, bottom: { style: 'thin', color: { rgb: '000000' } }, left: { style: 'thin', color: { rgb: '000000' } } }, };
ws['D4'].s = { font: { sz: 9, color: { rgb: '000000' }, name: 'SimSun' }, alignment: { horizontal: 'left', vertical: 'middle' }, border: { top: { style: 'thin', color: { rgb: '000000' } }, right: { style: 'thin', color: { rgb: '000000' } }, bottom: { style: 'thin', color: { rgb: '000000' } }, left: { style: 'thin', color: { rgb: '000000' } } }, };
ws['D5'].s = { font: { sz: 9, color: { rgb: '000000' }, name: 'SimSun' }, alignment: { horizontal: 'left', vertical: 'middle' }, border: { top: { style: 'thin', color: { rgb: '000000' } }, right: { style: 'thin', color: { rgb: '000000' } }, bottom: { style: 'thin', color: { rgb: '000000' } }, left: { style: 'thin', color: { rgb: '000000' } } }, };
ws['E4'].s = { font: { sz: 9, color: { rgb: '000000' }, name: 'SimSun' }, alignment: { horizontal: 'left', vertical: 'middle' }, border: { top: { style: 'thin', color: { rgb: '000000' } }, right: { style: 'thin', color: { rgb: '000000' } }, bottom: { style: 'thin', color: { rgb: '000000' } }, left: { style: 'thin', color: { rgb: '000000' } } }, };
ws['E5'].s = { font: { sz: 9, color: { rgb: '000000' }, name: 'SimSun' }, alignment: { horizontal: 'left', vertical: 'middle' }, border: { top: { style: 'thin', color: { rgb: '000000' } }, right: { style: 'thin', color: { rgb: '000000' } }, bottom: { style: 'thin', color: { rgb: '000000' } }, left: { style: 'thin', color: { rgb: '000000' } } }, };
ws['D14'].s = { font: { sz: 9, color: { rgb: '000000' }, name: 'SimSun' }, alignment: { horizontal: 'left', vertical: 'middle' }, border: { top: { style: 'thin', color: { rgb: '000000' } }, right: { style: 'thin', color: { rgb: '000000' } }, bottom: { style: 'thin', color: { rgb: '000000' } }, left: { style: 'thin', color: { rgb: '000000' } } }, };
ws['E14'].s = { font: { sz: 9, color: { rgb: '000000' }, name: 'SimSun' }, alignment: { horizontal: 'left', vertical: 'middle' }, border: { top: { style: 'thin', color: { rgb: '000000' } }, right: { style: 'thin', color: { rgb: '000000' } }, bottom: { style: 'thin', color: { rgb: '000000' } }, left: { style: 'thin', color: { rgb: '000000' } } }, };
ws['E10'].s = { font: { sz: 9, color: { rgb: '000000' }, name: 'SimSun' }, alignment: { horizontal: 'left', vertical: 'middle' }, border: { top: { style: 'thin', color: { rgb: '000000' } }, right: { style: 'thin', color: { rgb: '000000' } }, bottom: { style: 'thin', color: { rgb: '000000' } }, left: { style: 'thin', color: { rgb: '000000' } } }, };
const wb = XLSX.utils.book_new(); XLSX.utils.book_append_sheet(wb, ws, 'Sheet1');
// 生成 Excel 文件 XLSX.writeFile(wb, '配送捐赠药物说明书.xlsx');
// 导出 Excel 文件 // XLSX.writeFile(wb, '配送捐赠药物说明书.xlsx', { bookType: 'xlsx', type: 'buffer' });
// 导出为 csv 文件 // XLSX.writeFile(wb, '配送捐赠药物说明书.csv', { bookType: 'csv', type: 'buffer' });
原文地址: https://www.cveoy.top/t/topic/oid4 著作权归作者所有。请勿转载和采集!