What is the correct string formatting structure for Google Apps Scripts - as per the documentation.
Is this about how C formatting works?
I cannot figure how to write sprintf-like string formatting using '%'-style format strings.
I am using Google Apps Scripts to copy data from a spreadsheet, process the data in memory, then replace text placeholders in a Google Doc with the processed data.
Some of the data includes numbers, intended to represent currency, and these are placed into tables.
I have written a simple function to format the strings...
function formatStringCurrency(tempValue) {
// Description
return Utilities.formatString("$%d,%3.2f", tempValue/1000, tempValue%1000);
}
and I parse the necessary data through this function to prepare a "currency-like" string.
My problem - my formatting function works perfectly unless the string is over 1,000, and is also a multiple of 1000, that is, does not contain hundreds or less.
For example, here is a screenshot sample of my current output...
The second row is intended to display $3,000.00 and $12,000.00.
I have thought about formatting the Google Doc table, however that is not yet possible either manually or programmatically.
I have also attempted to remove all formatting from the numbers as they are represented in the original spreadsheet, however this does not make a difference.
As always, any assistance would be appreciated.