exceloffice-jsoffice-addinsexcel-addinsexcel-web-addins

Format Range as Currency - Excel Javascript


I'm trying to format a cell as Currency via Excel JavaScript API. I've tried currency and $ but neither work.

What do I need to do?

var Rev_Rng = ws.getRangeByIndexes(2, Header_Arr.indexOf("Est. Revenue"), Used_Rng_And_Props.rowCount - 2, 1)
Rev_Rng.select()
await context.sync()
Rev_Rng.numberFormat = '$'; //This just inserted '$' as the value I also tried 'currency'

Solution

  • Try to use something like that for the currency format:

    "$#,###.00"
    

    See Number format codes for more information.