const XLSX = require('xlsx');

const data = [ ['新生可期-复发套细胞淋巴瘤患者援助项目项目'], ['配送捐赠药物说明书'], ['接收药房:'], ['接收地址:'], ['配送单号:', '', '装箱时间:'], ['药品名称', '药品规格', '药品规格', '药品批号', '有效期', '数量'] ];

const ws = XLSX.utils.aoa_to_sheet(data);

const range = { s: { c: 0, r: 0 }, e: { c: 5, r: 5 } }; ws['!merges'] = [{ ...range }];

const borderStyle = { border: { top: { style: 'thin', color: { auto: 1 } }, bottom: { style: 'thin', color: { auto: 1 } }, left: { style: 'thin', color: { auto: 1 } }, right: { style: 'thin', color: { auto: 1 } } } };

for (let i = 0; i < 6; i++) { for (let j = 0; j < 6; j++) { if (i === 0) { XLSX.utils.cell_set_font(ws[XLSX.utils.encode_cell({ r: i, c: j })], { bold: true, size: 18, color: { rgb: "000000" } }); XLSX.utils.cell_set_alignment(ws[XLSX.utils.encode_cell({ r: i, c: j })], { horizontal: "center", vertical: "center" }); } else if (i === 1) { XLSX.utils.cell_set_font(ws[XLSX.utils.encode_cell({ r: i, c: j })], { bold: true, size: 14, color: { rgb: "000000" } }); XLSX.utils.cell_set_alignment(ws[XLSX.utils.encode_cell({ r: i, c: j })], { horizontal: "center", vertical: "center" }); } else { XLSX.utils.cell_set_font(ws[XLSX.utils.encode_cell({ r: i, c: j })], { size: 9, color: { rgb: "000000" } }); XLSX.utils.cell_set_border(ws[XLSX.utils.encode_cell({ r: i, c: j })], borderStyle); XLSX.utils.cell_set_alignment(ws[XLSX.utils.encode_cell({ r: i, c: j })], { horizontal: "left", vertical: "center" }); } } }

const wb = XLSX.utils.book_new(); XLSX.utils.book_append_sheet(wb, ws, "Sheet1"); XLSX.writeFile(wb, "output.xlsx");


原文地址: https://www.cveoy.top/t/topic/oifU 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录