[英]How to format a cell header in xlsx angular
如何使用 xlsx 或 cellStyles 格式化 angular 中的单元格。
这是代码。
list.component.ts
const ws = XLSX.utils.json_to_sheet(reportData);
ws['!cols'] = [];
Object.keys(reportData[0]).forEach((cell: any) => {
const colWidth =
cell === 'Date'
? 120
: cell === 'Time'
? 100
: cell === 'Location'
? 200
: cell === 'Temperature'
? 80
: cell === 'Humidity'
? 80
: 100;
ws['!cols'].push({
wpx: colWidth
});
});
XLSX.utils.book_append_sheet(wb, ws, this.roomTitle);
XLSX.writeFile(
wb,
`${fileName}.xlsx`,
{ cellStyles: true },
);
我在这里要做的是将其格式化为粗体BOLD TEXT
header 即Date, Time, Location, Temperature and Humidity
你试过跟随吗?
bold = workbook.add_format({'bold': True});
根据文档,您必须添加格式。
write(row, column, token, [format])
这会像,
worksheet.write(row, 0, 'Total', bold)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.