empty cells in appending data one by one into the google sheet via api v4

36 Views Asked by At

When i append the list of data in a column the data appended leaves the rows equivalent to the maximum rows used in the previous column and then starts appending from the last cell. The picture would explain the problem quite well. I am using flutter and gsheets dependency to connect to the sheet. Date is the column key and data is the data being appended.

if (column != null) {
  if (!column.contains(data)) {
    await sheet.values.map.appendRow({date: data});
  }
  return true;
} else {
  await sheet.values.insertColumnByKey(date, [data]);
  return true;
}

Current output

Required output

1

There are 1 best solutions below

0
On

You should find the last cell that contains a value in the target column and insert values starting in the cell just below that cell, instead of appending after the last row of the occupied data range in the sheet.

One way to do that is to use my appendRows_() utility function.