I'm using a web app to send data to Google Sheets via Apps Script. I'm using 'appendrow' to post several variables. Everything works fine but one variable is a number, call it 'Amount'. I found out that I can type a Google Sheets type formula in my web app such as '=10-5', '=10*2', '=10/2' and when it gets posted to my Google Sheets it provides the expected result. Good! However, if I type '=10+5', I get an error in my Google Sheets. When I look at the formula bar, it shows '10 5'. Why does it not show the formula as '=10+5'? The previous examples that I gave all show the expected formula in the formula bar.
function doGet(e) {
// I cannot take credit for this script. I copied and modified it from another user.
var ss = SpreadsheetApp.openById("FILE ID GOES HERE")
var sh = ss.getSheetByName("Register"); //sheet name is 'Register'
var date = e.parameter.date;
e.parameter.date = '1/2/2023'
var amount = e.parameter.amount;
var paytype = e.parameter.paytype;
var payid = e.parameter.payid;
var maincat = e.parameter.maincat;
var subcat = e.parameter.subcat;
var explanation = e.parameter.explanation;
sh.appendRow([date, amount, paytype, payid, maincat, subcat,
explanation]);
}
So when data get passed to Google Sheets via the sh.appendRow, the amount always works correctly when it contains, for example:
'10.52', '=10-5', '=10*2', '=10/2', but not '=10+5'. Instead, I get '10 5' and shows an error in the spreadsheet cell.
You may have guessed that I am a novice when it comes to script.
Thank you for any ideas.