最終列の取得
Google App Script(GAS)で最終列を取得する構文です。
構文
Sheetオブジェクト.getLastColumn()
引数
なし
戻り値
Integer
サンプル
function sample() {
// アクティブなスプレッドシートを取得
const spreadSheet = SpreadsheetApp.getActiveSpreadsheet();
// 指定したシートの取得
const sheet = spreadSheet.getSheetByName("シート1");
// 最終行の取得
const lastRow = sheet.getLastColumn();
Logger.log(lastRow);
}
解説
シートの中全体の最終列を取得します。