Search code examples
javascriptexceljs

How to display '-' character in a cell when actual value is 0 (Zero) in ExcelJS


This is easily done on Excel with custom formatting; but I don't find out how to do it programmatically in Javascript (ExcelJS). I don't want to replace the value, just how it is displayed.

view excel sheet


Solution

  • I found the way to accomplish this, it may help others. So here is it:

    worksheet.getCell('A1').numFmt = '_(#,##0_);_( (#,##0);_( \\-\\ ??_);_(@_)';