くら
GASでスプレッドシートの指定範囲すべての水平方向の位置を取得する方法を紹介します!
指定範囲すべての水平方向の位置を取得:getHorizontalAlignments()
指定範囲すべての水平方向の位置を取得します。
パラメータ
名前 | タイプ | 説明 |
---|---|---|
なし | なし | なし |
戻り値
String[][] | 水平方向の情報が入っている2次元配列 |
説明
function myFunction() {
const sheet = SpreadsheetApp.getActiveSheet();
const ss = SpreadsheetApp.getActiveSpreadsheet();
const range = ss.getSheetByName("サンプルA").getRange("A1:C1");
const horizontalAlignments = range.getHorizontalAlignments();
// A1:C1範囲の水平方向の位置を取得する
for (let row in horizontalAlignments) {
for (let col in horizontalAlignments[row]) {
console.log(horizontalAlignments[row][col]);
}
}
}
A1:C1の水平方向の位置を取得してみます。
サンプルコードを実行すると、それぞれの水平方向の位置を取得することができました!
公式ドキュメント:Range > getHorizontalAlignments()
まとめ
くら
スプレッドシートの指定範囲すべての水平方向の位置を取得する方法でした!
コメント