Google Sheets – Incrementing Value Read from Spreadsheet Exploding

google sheetsgoogle-apps-script

I read a value (in this case 7) from a Google Spreadsheet with a script, increase that value using source++ and write the increment back to the spreadsheet.

I expect a series of 7, 8, 9, 10.

Instead, I get 7, 800 000 000 000, 900 000 000 000, 100 000 000 000.

(Please note the 900 billion to 100 billion “increase.”)

source = (source+1) behaves identical.

What's going on here?

MWE:
https://docs.google.com/spreadsheets/d/1I98atMSUqwsEpt_EMjbHm1sdWQg5Bgn8ABsEz-2E2wE/edit?usp=sharing

Best Answer

This is a known bug in new Sheets whereby the spreadsheet regional settings generate an incorrect output. From the entry on this duplicate issue ticket:

If regional settings are set to US then setValue/setValues works properly. If regional settings are German, Polish, Russia and possibly others then there are different results! Polish - 1.00000000000000 German - 100.000.000.000

[For Google Apps Script questions you may get a better response in Stackoverflow]