const XLSX = require('xlsx');

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

const ws = XLSX.utils.aoa_to_sheet(data); ws['!cols'] = [{ width: 20 }, { width: 20 }, { width: 20 }, { width: 20 }, { width: 20 }, { width: 20 }]; ws['!rows'] = [{ hpt: 30, hpx: 30 }, { hpt: 30, hpx: 30 }, { hpt: 30, hpx: 30 }, { hpt: 30, hpx: 30 }, { hpt: 30, hpx: 30 }, { hpt: 20, hpx: 20 }];

const range = XLSX.utils.decode_range(ws['!ref']); for (let R = range.s.r; R <= range.e.r; ++R) { for (let C = range.s.c; C <= range.e.c; ++C) { const cell = XLSX.utils.encode_cell({ r: R, c: C }); ws[cell].s = { border: { top: { style: 'thin', color: { auto: 1 } }, right: { style: 'thin', color: { auto: 1 } }, bottom: { style: 'thin', color: { auto: 1 } }, left: { style: 'thin', color: { auto: 1 } } }, font: { name: '宋体', sz: 9 }, alignment: { horizontal: 'left', vertical: 'center' } }; if (R === 0 || R === 1) { ws[cell].s.font.bold = true; ws[cell].s.alignment.horizontal = 'center'; } } }

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


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

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