Skip to content

Instantly share code, notes, and snippets.

@tajuszk
Last active November 6, 2020 22:26
Show Gist options
  • Save tajuszk/480281614b108c66a9e88b3e11e979dc to your computer and use it in GitHub Desktop.
Save tajuszk/480281614b108c66a9e88b3e11e979dc to your computer and use it in GitHub Desktop.
const startRow = 1
const startCol = 1
const endRow = sheetData.getLastRow() // 最終行
const endCol = sheetData.getLastColumn() // 最終列
// 悪い例
for (let i = startRow; i <= endRow; i++) {
    // 行数分getRangeとgetValueが実行される
const cell = sheetData.getRange(i, startCol, 1, endCol).getValue();
// 実行する
execFunction(cell)
}
// 良い例
// 一度にまとめて取得する
const cell = sheetData.getRange(startRow, startCol, endRow, endCol).getValue();
for (let i = 0; i < cell.length; i++) {
    const cell = cells[i]
// 実行する
execFunction(cell)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment