I am using the following script to import data from another Google Sheet but it doesn´t bring in the formula I need with it.
I have tried ImportRange
but
getValues()
range#getFormulas
and range#getValues
and mix those two arrays to create a array of formulas and values to setValues()
later. var data = range.getValues();
data = range.getFormulas().map(function(e, i) {//i=index of row(e)
return e.map(function(f, j) {//j = index of column(f)
return f === "" ? data[i][j] : f;
});
});
or
var req = {
ranges: 'results!2:688',
valueRenderOption: 'FORMULA', //get formulas with values
};
var r = Sheets.Spreadsheets.Values.batchGet('Sheet 1 ID', req);
data = r.valueRanges[0].values;