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'] = [{start: {c: 0, r: 0}, end: {c: 5, r: 0}}, {start: {c: 0, r: 1}, end: {c: 5, r: 1}}];

ws['!cols'] = [ {wch: 15}, {wch: 15}, {wch: 15}, {wch: 15}, {wch: 15}, {wch: 15} ];

ws['B1'].s = { font: {bold: true}, alignment: {horizontal: 'center', vertical: 'center'} };

ws['B2'].s = { font: {bold: true}, alignment: {horizontal: 'center', vertical: 'center'} };

for(let i=2; i<=5; i++){ ws[XLSX.utils.encode_cell({c: 0, r: i})].s = {border: {bottom: {style: 'thin', color: {auto: 1}}}, font: {sz: 9}}; ws[XLSX.utils.encode_cell({c: 0, r: i})].s.alignment.horizontal = 'left'; }

for(let i=2; i<=5; i++){ ws[XLSX.utils.encode_cell({c: 1, r: i})].s = {border: {bottom: {style: 'thin', color: {auto: 1}}}, font: {sz: 9}}; ws[XLSX.utils.encode_cell({c: 1, r: i})].s.alignment.horizontal = 'left'; }

for(let i=2; i<=5; i++){ ws[XLSX.utils.encode_cell({c: 2, r: i})].s = {border: {bottom: {style: 'thin', color: {auto: 1}}}, font: {sz: 9}}; ws[XLSX.utils.encode_cell({c: 2, r: i})].s.alignment.horizontal = 'left'; }

for(let i=2; i<=5; i++){ ws[XLSX.utils.encode_cell({c: 3, r: i})].s = {border: {bottom: {style: 'thin', color: {auto: 1}}}, font: {sz: 9}}; ws[XLSX.utils.encode_cell({c: 3, r: i})].s.alignment.horizontal = 'left'; }

for(let i=2; i<=5; i++){ ws[XLSX.utils.encode_cell({c: 4, r: i})].s = {border: {bottom: {style: 'thin', color: {auto: 1}}}, font: {sz: 9}}; ws[XLSX.utils.encode_cell({c: 4, r: i})].s.alignment.horizontal = 'left'; }

for(let i=2; i<=5; i++){ ws[XLSX.utils.encode_cell({c: 5, r: i})].s = {border: {bottom: {style: 'thin', color: {auto: 1}}}, font: {sz: 9}}; ws[XLSX.utils.encode_cell({c: 5, r: i})].s.alignment.horizontal = 'left'; }

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

XLSX.writeFile(wb, 'example.xlsx');

使用 xlsx.js 生成 Excel 导出代码:复发套细胞淋巴瘤患者援助项目配送单

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

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