Changing font color while adding row in exceljs

Srujan Reddy picture Srujan Reddy · Jul 12, 2017 · Viewed 12.3k times · Source

As per the documentation, Changing font color of a particular cell is possible in this way:

sheet.addRow([
    'alex', 
    {
        text: 'image',
        hyperlink: 'http://something.com' //trying to change color of this cell
    }
])

sheet.getRow(1).getCell(2).font = {color: {argb: "004e47cc"}};

But, How do i specify styles while adding a row itself. (something like below).

sheet.addRow([
    'alex', 
    {
        text: 'image', 
        hyperlink: 'http://something.com', 
        font: {color: {argb: '004e47cc'}}
    }
])

My ultimate goal is to change color and underline all Hyperlinks in the sheet (**Hyperlinks are in random cells). Is there a better solution?

Answer

code_kbd picture code_kbd · Jan 28, 2019

It is indeed possible to change the background color when adding a row;

let row = workSheet.addRow(rowValues);
            row.fill = {
                type: 'pattern',
                pattern:'solid',
                fgColor:{argb:'#000000'},
                bgColor:{argb:'#FF0000'}
            };