Formatting a value as a string

A common question I get asked when people are merging values from a Google spreadsheet into a GDoc and/or PDF is how to format the values. So I have written this formatString() function.

For example if you wanted to use it in the createPdf() function the main for-loop would be replaced with:

for (;columnIndex < headerRow[0].length; columnIndex++) {
  var nextValue = formatString(activeRow[0][columnIndex])
  var header = headerRow[0][columnIndex]
  copyBody.replaceText('%' + header + '%', nextValue)
}

Share

2 thoughts on “Formatting a value as a string”

  1. Pingback: Google Apps Script to create PDF - Andrew Roberts

  2. Pingback: Homepage

Leave a Comment

Scroll to Top