I cannot change cell format with . setNumberFormat in google app script

Asked

Viewed 18 times

0

I made the following registration page. I need to pick up exactly the amount of zeroes I add to the registration field

página de cadastro

However, when this data is added to the spreadsheet, only a zero appears.

dados na planilha

I am trying to use . setFormatNumber as follows: inserir a descrição da imagem aqui

I’m trying to change the formatting of the entire column to plain text before making the append with a new data, but continues as automatic formatting in the same way. How do I change this formatting?

1 answer

-1


By doing the manual input tests and referencing the value from one cell to another, the format that influences the final record is that of the cell where the entree, then in your case it would still be on the form, and how is accepted this value.

EXAMPLE:

  • Matrícula = 0000012 -> manual entry

  • Before the appendRow(): Matrícula = 12 -> reduced number for access in a "temporary cell" (I call this because I don’t know exactly how the transition from form to worksheet works before the call of the addStudent function()

  • After the appendRow(): Aluno01 || 12 || 2001-06-03

Therefore, if at the time you are registering the registration the number is ignoring the zeros on the left (by being formatted as number, not plain text), at the time you do the appendRow(), you will be throwing the value not formatted to a formatted cell, which will receive the value already reduced.

Meanwhile, formatting as plain text for the sheet records column can be done either manually for the entire column, or before the if(), not to execute the command for each new record.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.