How do you format currency in exceljs?
All I've found is this from their docs...which I have no clue how to type so I pasted it, but it doesn't seem to work
// Set Column 3 to Currency Format
ws.getColumn(3).numFmt = '�#,##0;[Red]-�#,##0';
United States (U.S.) currency is formatted with a decimal point (.) as a separator between the dollars and cents. Some countries use a comma (,) instead of a decimal to indicate that separation.
When you apply the Currency format to a number, the currency symbol appears right next to the first digit in the cell. You can specify the number of decimal places that you want to use, whether you want to use a thousands separator, and how you want to display negative numbers.
In Excel, you can format numbers in cells for things like currency, percentages, decimals, dates, phone numbers, or social security numbers. Select a cell or a cell range. On the Home tab, select Number from the drop-down.
Just took a little bit of tinkering with.
ws.getColumn(3).numFmt = '$#,##0.00;[Red]-$#,##0.00';
The #'s are optional digits. If you don't care about negative numbers being red you can leave it as $#,##0.00
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With