As I know
appendRow(rowContents) add values to the bottom of the spreadsheet But how to add data from form in multiple rows in top of spreadsheet?
So if in form i have rows
- first, surname, name
- second, surname, name
- third, surname, name
in sheet it must be placed as, and each time to the top
so if another time in form will be
- fourth, surname, name
- fifth, surname, name
- six, surname, name
data will be added like
Now I using this code, but it append all data to the end and works only with one row, i think i must loop throught all rows in form but how to do that?
function getValuesFromForm(form){
var firstName = form.firstName,
lastName = form.lastName,
order = form.order,
sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
sheet.appendRow([order,lastName,firstName]);
}
There's no single function to do this, but it's not that difficult write one. Here's an example:
I would actually allow for an optional index, let's say we want to insert after the 2nd row, skipping the header.
But
appendRow
also has another interesting characteristic, it's concurrent-safe. Which means it can be triggered multiple times in parallel and won't mess up. To make our function concurrent safe you have tolock
it, like this:Then, to use it in your code just call..