StorageB/Google-Sheets-Logging

change a dot to a comma

Robisy opened this issue · 2 comments

6E33D1B3-7604-4379-9213-B9B9EF501AE4
Hello, i export tempearture by bme280 to google sheet. How can I change dots to commas? from 21.23 to 21,23

P.s.
changing the zone in the sheet doesn't help :)

Regards

Because the ESP8266 code uses commas to separate the multiple values sent to Google Sheets, it is easier to make this change in the Google Script code after the string of values are received from the ESP8266 and are separated and stored as separate variables.

First, in your Google Sheets spreadsheet go to File > Settings and verify that the Locale is set to a region that uses that number format (such as Germany).

Using the example code, let's assume the "value2" variable is the number you wish to convert. In the Google Script code, add this line of code after value2 is declared and the value from the ESP8266 is assigned to it:

value2 = value2.toString().replace(".", ",");

Screenshot from 2023-01-25 16-01-35

This converts the value received from the ESP8266 to a string, and replaces the decimal point with a comma before it gets published to the spreadsheet.

Lastly, you may need to make sure the column containing the values is formatted correctly. In Google Sheets highlight the entire column, and go to Format > Number, and select the Number format.

Google Sheets should now recognize this value as a number formatted as 0.000,00.

Screenshot from 2023-01-25 16-19-27

Note that when making changes to the Google Scripts code, you will need to click Save then Deploy > New deployment for any new changes to take effect. You will be given a new Deployment ID that you will have to update in the ESP8266 code each time (each new deployment is given a new Deployment ID).

6E33D1B3-7604-4379-9213-B9B9EF501AE4 Hello, i export tempearture by bme280 to google sheet. How can I change dots to commas? from 21.23 to 21,23

P.s. changing the zone in the sheet doesn't help :)

Regards

Hello, do you use function doGET or doPOST?

If you use doPOST, can u post here you code?