Home > Software engineering >  Google Apps Script - force setValue to text
Google Apps Script - force setValue to text

Time:04-14

I am using setValue() to put values from an array into spreadsheet cells. Some array elements contain data that is text, but is being parsed as numeric, eg: "6E5", and setValue() converts them (in that case the cell gets the numeric value 600000). Is there any way to force the cell to be a text value?

CodePudding user response:

I think you're looking to set the number format. Do this before you setValue. See example below. You could also create all of your array values to be a formula. Example ="6E5" see an answer enter image description here

Example WITHOUT setting format: enter image description here]

  • Related