Search code examples
node.jsexcelexceljs

Is there any way to find the value of a cell in excel depending on the font colour by Using ExcelJs in NodeJS


Is there any way to find the value of a cell in excel depending on the font colour by Using ExcelsJs in NodeJS

for example, I want to get all values inside an excel where they are colour font is grey

I am using a Nodejs, with exceljs if there any suggesting, I will be very thankful this photo from one sheet where I need to find a solution

enter image description here


Solution

  • It seems they don't have a special method to search a certain cells y different criteria but you can do it yourself by iterating all cells like this:

    const rows = worksheet.getRows(1, worksheet.rowCount)
    
    const foundCells = []
    for (const row of rows) {
      const cells = row.
      for (let cIndex = 1; cIndex <= worksheet.columnCount; cIndex++) {
        const cell = row.getCell(cIndex);
        if (cell.font.bold) {
          foundCells.push(cell);
        }
      }
    }