exceljs icon indicating copy to clipboard operation
exceljs copied to clipboard

[BUG] font parameter is being overwritten if used in the same row for different cells

Open marcio3457 opened this issue 8 months ago • 1 comments

🐛 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):


marcio3457 avatar May 30 '25 23:05 marcio3457

// 这里由于相同的对象引用直接赋值会影响其它单元格,所以需要克隆原始样式并创建新的对象。
cell.font = {
	...(cell.style.font || {}),
	color: {argb: 'FF0000FF'},
};

LSL1618 avatar Jun 18 '25 03:06 LSL1618