I'm copying financial values from a Google Spreadsheet to a Google Doc and applying formatting all with Google Apps Script. Since financial numerical formatting doesn't stick when values are entered in Google Doc I've had to find ways around that to have data viewable as $10,000.00 or $560,800.50, etc.
However, now I'm trying to get the numbers to line up nicely in the table they've been appended to in Google Docs (again, using GAS). This would be most ideally solved if I could set the TabStop position of the Google Doc via GAS. Is this possible?
I'm already using a function that adds commas every three digits (before the decimal point), but now I essentially want to format the values as if they're formatted for "accounting" like in Google Sheets. You know, where the dollar sign ($) is aligned on the left and there's essentially a large white space in between and then the numbers are aligned to the right.
You'll see in my code below that I've been using the \t to add the white space between the $ and the values, however depending upon the number of digits it staggers the $ if that makes sense so it looks messy.
for (var i = 0; i < item.length; i++) {
var data0 = [item[i],dows[i],"$\t"+numberWithCommas(sovs[i])];
data.push(data0);
}
Currently the output looks like this:
$ 10,000.00
$ 560,800.50
$ 600.00
$ 4,000.00
But I would LOVE it if the output looked like this:
$ 10,000.00
$ 560,800.50
$ 600.00
$ 4,000.00