Looking to enhance the visual representation of numeric string data by displaying it in different colors based on whether the number is positive or negative.
Current code snippet:
var url = 'https://docs.google.com/spreadsheets/d/xxxxxxxxxxxxxxxxxxxxxx/edit#gid=xxxxxxxxx';
var spreadSheet = SpreadsheetApp.openByUrl(url);
var allSheets = spreadSheet.getSheets();
var theSheet = allSheets[1];
var lastRow = theSheet.getLastRow();
var lastColumn = theSheet.getLastColumn();
var sheetData = theSheet.getSheetValues(1, 1, lastRow, lastColumn);
var rawData = sheetData[1][1];
var calcData = sheetData[1][1] / sheetData[0][1];
var formattedData = Utilities.formatString("%+1.2f%", calcData * 100);
Result for formattedData
:
+12.1%
Considering formatting this output with green letters for positive numbers and red letters for negative numbers.
Related question: .setNumberFormat is not working in Google Apps Script