Home > other >  Change format of devise in apps script
Change format of devise in apps script

Time:09-16

I've a Sheets with many values in euro with 3 values after the decimal point (for exemple (2,154 €). I would like to convert this document in PDF to join it in mail.

When I convert it in temporary Sheet, this value change and I have 2.154 instead of. I would like to change the format of this cell.

So I decided to apply a setFormatNumber (.setNumberFormat('#,###.000 [$€]')) at this value but I don't get the result what I want. I obtain 2.154 € but I would like to have "," an not "." to separe entire to decimal values. I try to modify setFormatNumber by (.setNumberFormat('#,###,000 [$€]')) but my result is 2.154000 €.

I don't want to apply toString method and use replace method after because I think it's possible to have what I want by using this method.

Anyone can help me with that please ? I don't join my code because it's so long and, except the setNumberFormat, it's not interesting for you but if you need it, I can edit my post. Sorry for my english, I don't speak and write it very well.

CodePudding user response:

Dots and commas have other meanings in the context of this “mask”-like parameter.

The numberFormat parameter of the setNumberFormat() is documented here.

According to the documentation, dots indicate where the decimal separator will be in the mask and commas indicate where the thousand separator will be.

The symbol of the decimal separator is however controlled according to the Spreadsheet locale settings. You can change those settings via UI going to File > Settings > General > Locale or via Apps Scripts using the method SpreadsheetApp.getActive().setSpreadsheetLocale('XXXXX')

  • Related