
くら
GASでスプレッドシートの指定セルの垂直方向を取得する方法を紹介します!
指定セルの垂直方向を取得:getVerticalAlignment()
指定セルの垂直方向を取得します。
パラメータ
名前 | タイプ | 説明 |
---|---|---|
なし | なし | なし |
戻り値
String | 垂直方向の文字列 |
説明
function myFunction() {
const sheet = SpreadsheetApp.getActiveSheet();
const ss = SpreadsheetApp.getActiveSpreadsheet();
// 垂直方向:上
let range = ss.getSheetByName("サンプル").getRange("A1");
console.log(range.getVerticalAlignment());
// 垂直方向:中央
range = ss.getSheetByName("サンプル").getRange("A2");
console.log(range.getVerticalAlignment());
// 垂直方向:下
range = ss.getSheetByName("サンプル").getRange("A3");
console.log(range.getVerticalAlignment());
}
指定セルの垂直方向の配置を取得します。

サンプルコードを実行すると、top middle bottom という文字列を取得することができました!

公式ドキュメント:Range > getVerticalAlignment()
まとめ

くら
スプレッドシートの指定セルの垂直方向を取得する方法でした!
コメント