Even with gsheet v2.1, users make mistakes. Here are the top three and their solutions.
function getLastDataRow(sheet, column = 1)
const values = sheet.getRange(1, column, sheet.getMaxRows()).getValues();
for (let i = values.length - 1; i >= 0; i--)
if (values[i][0] && values[i][0].toString().trim() !== "") return i + 1;
return 0;
One of the most celebrated features of the gsheet v2.1 framework is the batchUpdate method. Instead of modifying cells one by one, you build a single payload.
// GSheet v2.1 batch write example
const updates = [
range: "A2:A100", values: [[timestamp], [timestamp2], ...] ,
range: "B2:B100", values: [["Completed"], ["Pending"], ...]
];
sheet.batchUpdate(updates);
Performance gain: Up to 40x faster for large datasets (10,000+ cells).