Answer the question
In order to leave comments, you need to log in
How to insert a string into a Google sheet cell instead of a formula?
Hello.
How to insert a string into a Google sheet cell instead of a formula?
Line such
"94,05 грн.+ 60 грн."
Tried on everyone. Here is the code
async function getProductsById () {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet1 = ss.getSheetByName('Продажи на Prom ua');
var spreadsheet = SpreadsheetApp.getActive();
let x = 0;
var price;
var str= "";
var headers = {
'Authorization': 'Bearer *******************************',
'contentType': 'application/json; charset=utf-8'
};
var options = {
'method' : 'get',
'headers': headers
};
while (x < 10) {
var result = await UrlFetchApp.fetch('https://my.prom.ua/api/v1/orders/113203508', options);
if (result) {break;}
x++
};
orderList = JSON.parse(result.getContentText());
var lngth = orderList["order"]['products'].length;
for (let i = 0; i<lngth; i++ ){
price = orderList["order"]['products'][i]['price'];
if(i<lngth-1){
str= str + price + '+ '+' ';
}
else {str= str + price}
}
var lr = sheet1.getLastRow();
cell = sheet1.getRange(lr+1,1);
cell.setFormula('=A1000+B1000 '+ str);
//var orderList1 = JSON.stringify(orderList, null, 2);
//Logger.log(orderList1);
}
Answer the question
In order to leave comments, you need to log in
Rewrite like this:
cell.setFormula('" "&"' + str+'"');
or like this:
cell.setFormula('""&"' + str+'"');
Instead ,
write
This is just not the application of a formula, but "just a string", or rather, a value.
cell.setFormula('=A1000+B1000 '+ str);
cell.setValue('=A1000+B1000 '+ str);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question