exceljs
exceljs copied to clipboard
[BUG] font parameter is being overwritten if used in the same row for different cells
🐛 Bug Report
While using exceljs to change the font of diferent cells in the same row, the font is overwritten in both cells to the latest value, and it makes impossible to set font to diferente fields Lib version: 4.4.0
Steps To Reproduce
for(let i = 17; i < worksheetQuotation._rows.length+1; i++) {
var row = worksheetQuotation.getRow(i);
if(row .getCell(10).value == "TOTAL"){
break;
}
row.getCell(8).font = { name: 'Arial', size: 12, bold: false };
row.getCell(9).font = { name: 'Arial', size: 14, bold: true };
row.commit();
}
If you executed a for like this, the font argument of cell 8 gets the same value as the font argument of cell 9
and the xlsx shows fields in column 9 without bold and fields in column 8 with bold
The expected behaviour:
Possible solution (optional, but very helpful):
// 这里由于相同的对象引用直接赋值会影响其它单元格,所以需要克隆原始样式并创建新的对象。
cell.font = {
...(cell.style.font || {}),
color: {argb: 'FF0000FF'},
};