Diego Rios
Diego Rios

Reputation: 505

Currency format with GoogleScript

I'm trying to format cells to Peruvian Nuevo Sol (S/.00.00 - PEN). I'm using setNumberFormat.However I've tried several options and I can't get it to work.

This is the line of my script where I'm trying to format the cell:

  campaignSheet.getRange(i, 4).setNumberFormat("S/.00.00").setFormula("E"+i+"*3.5");

That i is there because it's in a loop.

Thanks!

Upvotes: 6

Views: 12081

Answers (1)

Dan
Dan

Reputation: 149

Try using .setNumberFormat("[$S/.]#,##00.00").

Full code would be:

campaignSheet.getRange(i, 4).setNumberFormat("[$S/.]#,##00.00").setFormula("E"+i+"*3.5");

Of note, you can remove the leading zero for numbers less than 10 (if desired) by using .setNumberFormat("[$S/.]#,##0.00") instead.

Hope this helps!

Upvotes: 6

Related Questions