Question Details

No question body available.

Tags

javascript node.js excel type-conversion exceljs

Answers (1)

July 23, 2026 Score: -1 Rep: 4,614 Quality: Low Completeness: 50%

You could try to utilize .toFixed(2). It converts a Float into a String, with as much decimals as specified.

I changed the if a bit to make the code overall shorter. Using cell.text != null is equivalent to cell.text !== null && cell.text !== undefined. Additionally, I refactored to get rid of the else branch and used the ternary operator to see if the value is a Number.

row.eachCell({ includeEmpty: true }, (cell) => {
  let cellValue = "";

if (cell.text != null) { cellValue = typeof cell.text === "number" ? cell.text.toFixed(2) : cell.text; }

rowValues.push(cellValue); });