7
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【GAS】1行で「交互の背景色」を実装する【スプレッドシート】【BandingTheme】

Last updated at Posted at 2019-12-06

##サンプル

// 1行なら
SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getRange("A1:C6").applyRowBanding(SpreadsheetApp.BandingTheme.LIGHT_GREEN);

function myBandingTheme() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sh = ss.getActiveSheet();

  sh.getRange("A1:C6").applyRowBanding(SpreadsheetApp.BandingTheme.LIGHT_GREEN);

}

便利すぎて泣ける.PNG

##ヘッダーとフッターの有無を設定したい場合

applyRowBanding(bandingTheme, showHeader, showFooter)

// 例:ヘッダー色 なし フッター色 あり
function myBandingTheme() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sh = ss.getActiveSheet();

  sh.getRange("A1:C6").applyRowBanding(SpreadsheetApp.BandingTheme.LIGHT_GREEN, false, true);

}

便利すぎ.PNG

##色の一覧
https://developers.google.com/apps-script/reference/spreadsheet/banding-theme

##参考
サンプル付きで同じ事をやっているページが存在しない(執筆当時)ため書きました

BandingThemeはSpreadsheetAppクラス

applyRowBandingはRangeクラス

7
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?