獲取單列中的最後一行
function lastRowForColumn(sheet, column){
// Get the last row with data for the whole sheet.
var numRows = sheet.getLastRow();
// Get all data for the given column
var data = sheet.getRange(1, column, numRows).getValues();
// Iterate backwards and find first non empty cell
for(var i = data.length - 1 ; i >= 0 ; i--){
if (data[i][0] != null && data[i][0] != ""){
return i + 1;
}
}
}