I need to push data into a spreadsheet via api but cant find the documentation to this.
each call should append one row of data after the last row that contains data into a specific worksheet. like a csv that gets written over time so to say.
I need to push data into a spreadsheet via api but cant find the documentation to this.
each call should append one row of data after the last row that contains data into a specific worksheet. like a csv that gets written over time so to say.
Hello @wuast94
In general, this can be done in following way with macro:
var oWorksheet = Api.GetSheet("Sheet1");
var data = "data to insert";
var oRange = oWorksheet.GetUsedRange();
var oCol = oRange.GetCols(1);
var oCount = oCol.GetCount();
console.log(oCount);
oRange.GetCells(oCount+1, 1).SetValue(data);
This example uses following methods: GetSheet, GetUsedRange, GetCols, GetCount, GetCells and SetValue.
Basically, this macro counts rows in specified column and then gets a cell in the next row of the range and inserts predefined data into it.
To get last row firstly following logic is used: get number of all rows in the used range and add 1 extra to get next row after used ones. For this example rows are selected from column A with method GetCols
.