同じシート内の 1 つ以上の Range インスタンスのコレクション。このクラスを使用すると、隣接しない範囲またはセルのコレクションに対してオペレーションを適用できます。
メソッド
詳細なドキュメント
activate()
Range インスタンスのリストを選択します。リストの最後の範囲が active range として設定されます。
注: これにより、複数の範囲を複数選択できます。
const sheet = SpreadsheetApp.getActiveSheet(); const rangeList = sheet.getRangeList(['D4', 'B2:C4']); rangeList.activate(); const selection = sheet.getSelection(); // Current cell: B2 const currentCell = selection.getCurrentCell(); // Active range: B2:C4 const activeRange = selection.getActiveRange(); // Active range list: [D4, B2:C4] const activeRangeList = selection.getActiveRangeList();
戻る
Range - 連鎖用の有効な範囲のリスト。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
break Apart()
範囲リストに含まれる水平方向または垂直方向に結合されたすべてのセルを、個々のセルに分割します。
範囲リストでこの関数を呼び出すことは、範囲のセットを選択して、[書式] > [結合] > [結合を解除] のスプレッドシート メニュー項目を選択することと同じです。
const sheet = SpreadsheetApp.getActiveSheet(); const rangeList = sheet.getRangeList(['A:A', 'C:C']); rangeList.breakApart();
戻る
Range - チェーン用のこの範囲リスト。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
check()
範囲内のチェックボックスの状態を「オン」に変更します。現在、構成されているオンまたはオフの値のいずれも含まれていない範囲内のセルは無視されます。
// Changes the state of cells which currently contain either the checked or // unchecked value configured in the ranges D4 and E6 to 'checked'. const rangeList = SpreadsheetApp.getActive().getRangeList(['D4', 'E6']); rangeList.check();
戻る
Range - チェーン用のこの範囲リスト。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
clear()
範囲リスト内の各 Range のコンテンツ、形式、データ検証ルールの範囲をクリアします。
const sheet = SpreadsheetApp.getActiveSheet(); const rangeList = sheet.getRangeList(['A:A', 'C:C']); rangeList.clear();
戻る
Range - チェーン用のこの範囲リスト。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
clear(options)
指定されたオプションに従って、コンテンツ、形式、データの入力規則、コメントの範囲をクリアします。デフォルトでは、すべてのデータが消去されます。
// The code below clears the contents of the following ranges A:A and C:C in the // active sheet, but preserves the format, data validation rules, and comments. const sheet = SpreadsheetApp.getActiveSheet(); const rangeList = sheet.getRangeList(['A:A', 'C:C']); rangeList.clear({contentsOnly: true});
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
options | Object | 以下に示す高度なパラメータを指定する JavaScript オブジェクト。 |
高度なパラメータ
| 名前 | 型 | 説明 |
|---|---|---|
comments | Boolean | コメントのみをクリアするかどうか。 |
contents | Boolean | コンテンツのみをクリアするかどうか。 |
format | Boolean | 書式のみをクリアするかどうか。書式をクリアすると、データの入力規則もクリアされることに注意してください。 |
validations | Boolean | データの入力規則のみをクリアするかどうか。 |
skip | Boolean | フィルタされた行のクリアを回避するかどうか。 |
戻る
Range - チェーン用のこの範囲リスト。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
clear Content()
範囲リスト内の各 Range の内容をクリアします。書式設定はそのまま残ります。
const sheet = SpreadsheetApp.getActiveSheet(); const rangeList = sheet.getRangeList(['A:A', 'C:C']); rangeList.clearContent();
戻る
Range - チェーン用のこの範囲リスト。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
clear Data Validations()
範囲リスト内の各 Range のデータ入力規則をクリアします。
const sheet = SpreadsheetApp.getActiveSheet(); const rangeList = sheet.getRangeList(['A:A', 'C:C']); rangeList.clearDataValidations();
戻る
Range - チェーン用のこの範囲リスト。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
clear Format()
範囲リスト内の各 Range のテキスト形式をクリアします。
これにより、各範囲のテキスト形式はクリアされますが、数値形式のルールはリセットされません。
const sheet = SpreadsheetApp.getActiveSheet(); const rangeList = sheet.getRangeList(['A:A', 'C:C']); rangeList.clearFormat();
戻る
Range - チェーン用のこの範囲リスト。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
clear Note()
範囲リスト内の各 Range のメモをクリアします。
const sheet = SpreadsheetApp.getActiveSheet(); const rangeList = sheet.getRangeList(['A:A', 'C:C']); rangeList.clearNote();
戻る
Range - チェーン用のこの範囲リスト。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Ranges()
insert Checkboxes()
範囲内の各セルにチェックボックスを挿入します。チェックされている場合は true、チェックされていない場合は false で構成されます。範囲内のすべてのセルの値を false に設定します。
const rangeList = SpreadsheetApp.getActive().getRangeList(['D4', 'E6']); // Inserts checkboxes into each cell in the ranges D4 and E6 configured with // 'true' for checked and 'false' for unchecked. Also, sets the value of each // cell in the ranges D4 and E6 to 'false'. rangeList.insertCheckboxes();
戻る
Range - チェーン用のこの範囲リスト。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
insert Checkboxes(checkedValue)
範囲内の各セルにチェックボックスを挿入します。チェックボックスがオンの場合はカスタム値、オフの場合は空の文字列が設定されます。範囲内の各セルの値を空の文字列に設定します。
const rangeList = SpreadsheetApp.getActive().getRangeList(['D4', 'E6']); // Inserts checkboxes into each cell in the ranges D4 and E6 configured with // 'yes' for checked and the empty string for unchecked. Also, sets the value of // each cell in the ranges D4 and E6 to the empty string. rangeList.insertCheckboxes('yes');
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
checked | Object | チェックボックスのデータ検証のチェックされた値。 |
戻る
Range - チェーン用のこの範囲リスト。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
insert Checkboxes(checkedValue, uncheckedValue)
範囲内の各セルにチェックボックスを挿入します。チェックボックスがオンの場合とオフの場合のカスタム値が設定されます。範囲内の各セルの値をカスタムの未チェックの値に設定します。
const rangeList = SpreadsheetApp.getActive().getRangeList(['D4', 'E6']); // Inserts checkboxes into each cell in the ranges D4 and E6 configured with // 'yes' for checked and 'no' for unchecked. Also, sets the value of each cell // in the ranges D4 and E6 to 'no'. rangeList.insertCheckboxes('yes', 'no');
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
checked | Object | チェックボックスのデータ検証のチェックされた値。 |
unchecked | Object | チェックボックスのデータ検証のチェックマークなしの値。 |
戻る
Range - チェーン用のこの範囲リスト。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
remove Checkboxes()
範囲からすべてのチェックボックスを削除します。各セルのデータ検証をクリアします。また、セルにオンまたはオフの値が含まれている場合は、その値もクリアします。
const range = SpreadsheetApp.getActive().getRange('A1:B10'); // Inserts checkboxes and sets each cell value to 'no' in the range A1:B10. range.insertCheckboxes('yes', 'no'); const rangeList1 = SpreadsheetApp.getActive().getRangeList(['A1', 'A3']); rangeList1.setValue('yes'); // Removes the checkbox data validation in cells A1 and A3 and clears their // value. rangeList1.removeCheckboxes(); const rangeList2 = SpreadsheetApp.getActive().getRangeList(['A5', 'A7']); rangeList2.setValue('random'); // Removes the checkbox data validation in cells A5 and A7 but does not clear // their value. rangeList2.removeCheckboxes();
戻る
Range - チェーン用のこの範囲リスト。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Background(color)
範囲リスト内の各 Range の背景色を設定します。色は CSS 表記で表されます(例: '#ffffff'、'white')。
const sheet = SpreadsheetApp.getActiveSheet(); const rangeList = sheet.getRangeList(['A:A', 'C:C']); rangeList.setBackground('red');
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
color | String | '#ffffff' や 'white' などの CSS 表記の背景色のコード。null 値は色をリセットします。 |
戻る
Range - チェーン用のこの範囲リスト。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Background RGB(red, green, blue)
背景を指定された RGB カラーに設定します。これは set 呼び出しの便利なラッパーです。
const sheet = SpreadsheetApp.getActiveSheet(); const rangeList = sheet.getRangeList(['A:A', 'C:C']); // Sets the background to red for each range in the range list. rangeList.setBackgroundRGB(255, 0, 0);
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
red | Integer | RGB 表記の赤色の値。 |
green | Integer | RGB 表記の緑色の値。 |
blue | Integer | RGB 表記の青の値。 |
戻る
Range - チェーン用のこの範囲リスト。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Border(top, left, bottom, right, vertical, horizontal)
範囲リスト内の各 Range の境界プロパティを設定します。有効な値は true(オン)、false(オフ)、null(変更なし)です。
const sheet = SpreadsheetApp.getActiveSheet(); const rangeList = sheet.getRangeList(['A2:B4', 'C1:D4']); // Sets borders on the top and bottom of the ranges A2:B4 and C1:D4, but leaves // the left and right unchanged. rangeList.setBorder(true, null, true, null, false, false);
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
top | Boolean | 枠線は true、なしは false、変更なしは null。 |
left | Boolean | 枠線は true、なしは false、変更なしは null。 |
bottom | Boolean | 枠線は true、なしは false、変更なしは null。 |
right | Boolean | 枠線は true、なしは false、変更なしは null。 |
vertical | Boolean | 内部の垂直方向の境界線は true、なしは false、変更なしは null。 |
horizontal | Boolean | 内部の水平罫線には true、なしには false、変更なしには null を使用します。 |
戻る
Range - チェーン用のこの範囲リスト。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Border(top, left, bottom, right, vertical, horizontal, color, style)
範囲リスト内の各 Range の枠線プロパティを色やスタイルで設定します。有効な値は true(オン)、false(オフ)、null(変更なし)です。色は CSS 表記で表されます(例: '#ffffff'、'white')。
const sheet = SpreadsheetApp.getActiveSheet(); const rangeList = sheet.getRangeList(['A2:B4', 'C1:D4']); // Sets borders on the top and bottom, but leaves the left and right unchanged // of the ranges A2:B4 and C1:D4. Also sets the color to 'red', and the border // to 'DASHED'. rangeList.setBorder( true, null, true, null, false, false, 'red', SpreadsheetApp.BorderStyle.DASHED, );
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
top | Boolean | 枠線は true、なしは false、変更なしは null。 |
left | Boolean | 枠線は true、なしは false、変更なしは null。 |
bottom | Boolean | 枠線は true、なしは false、変更なしは null。 |
right | Boolean | 枠線は true、なしは false、変更なしは null。 |
vertical | Boolean | 内部の垂直方向の境界線は true、なしは false、変更なしは null。 |
horizontal | Boolean | 内部の水平罫線には true、なしには false、変更なしには null を使用します。 |
color | String | '#ffffff' や 'white' などの CSS 表記の枠線の色。デフォルトの色(黒)の場合は null。 |
style | Border | 枠線のスタイル。デフォルトのスタイル(実線)の場合は null。 |
戻る
Range - チェーン用のこの範囲リスト。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Font Color(color)
範囲リストの各 Range のフォントの色を設定します。色は CSS 表記で表されます(例: '#ffffff'、'white')。
const sheet = SpreadsheetApp.getActiveSheet(); const rangeList = sheet.getRangeList(['A:A', 'C:C']); rangeList.setFontColor('red');
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
color | String | CSS 表記のフォントの色('#ffffff' や 'white' など)。null 値は色をリセットします。 |
戻る
Range - チェーン用のこの範囲リスト。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Font Family(fontFamily)
範囲リスト内の各 Range のフォント ファミリーを設定します。フォント ファミリーは、Arial や Roboto などの文字列識別子で記述されます。
const sheet = SpreadsheetApp.getActiveSheet(); const rangeList = sheet.getRangeList(['A:A', 'C:C']); rangeList.setFontFamily('Roboto');
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
font | String | 設定するフォント ファミリー。null 値を指定すると、フォント ファミリーがリセットされます。 |
戻る
Range - チェーン用のこの範囲リスト。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Font Line(fontLine)
範囲リスト内の各 Range のフォントの線スタイルを設定します。線のスタイル オプションは、'underline'、'line-through'、'none' です。
const sheet = SpreadsheetApp.getActiveSheet(); const rangeList = sheet.getRangeList(['A:A', 'C:C']); rangeList.setFontLine('line-through');
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
font | String | フォントの線スタイル('underline'、'line-through'、'none' のいずれか)。null 値を指定すると、フォントの線スタイルがリセットされます。 |
戻る
Range - チェーン用のこの範囲リスト。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Font Size(size)
範囲リスト内の各 Range のフォントサイズ(ポイント単位)を設定します。
const sheet = SpreadsheetApp.getActiveSheet(); const rangeList = sheet.getRangeList(['A:A', 'C:C']); rangeList.setFontSize(20);
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
size | Integer | フォントのポイント サイズ。 |
戻る
Range - チェーン用のこの範囲リスト。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Font Style(fontStyle)
範囲リストの各 Range のフォント スタイルを設定します。フォント スタイルのオプションは 'italic' または 'normal' です。
const sheet = SpreadsheetApp.getActiveSheet(); const rangeList = sheet.getRangeList(['A:A', 'C:C']); rangeList.setFontStyle('italic');
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
font | String | フォント スタイル('italic' または 'normal')。null 値はフォント スタイルをリセットします。 |
戻る
Range - チェーン用のこの範囲リスト。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Font Weight(fontWeight)
範囲リスト内の各 Range のフォントの太さを設定します。フォントの太さのオプションは 'normal' または 'bold' です。
const sheet = SpreadsheetApp.getActiveSheet(); const rangeList = sheet.getRangeList(['A:A', 'C:C']); rangeList.setFontWeight('bold');
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
font | String | フォントの太さ('bold' または 'normal')。null 値を指定すると、フォントの太さがリセットされます。 |
戻る
Range - チェーン用のこの範囲リスト。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Formula(formula)
範囲リスト内の各 Range の数式を更新します。指定された数式は A1 形式にする必要があります。
const sheet = SpreadsheetApp.getActiveSheet(); const rangeList = sheet.getRangeList(['A11', 'C11']); rangeList.setFormula('=SUM(B1:B10)');
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
formula | String | 設定する数式を表す文字列。 |
戻る
Range - チェーン用のこの範囲リスト。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Formula R1C1(formula)
範囲リスト内の各 Range の数式を更新します。指定された数式は R1C1 表記にする必要があります。
const sheet = SpreadsheetApp.getActiveSheet(); const rangeList = sheet.getRangeList(['A11', 'C11']); // This sets the formula to be the sum of the 3 rows above B5 rangeList.setFormulaR1C1('=SUM(R[-3]C[0]:R[-1]C[0])');
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
formula | String | 文字列の数式。 |
戻る
Range - チェーン用のこの範囲リスト。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Horizontal Alignment(alignment)
範囲リスト内の各 Range の水平方向の配置を設定します。配置オプションは 'left'、'center'、'right' です。
const sheet = SpreadsheetApp.getActiveSheet(); const rangeList = sheet.getRangeList(['A:A', 'C:C']); rangeList.setHorizontalAlignment('center');
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
alignment | String | 配置('left'、'center'、'normal' のいずれか)。null 値を指定すると、配置がリセットされます。 |
戻る
Range - チェーン用のこの範囲リスト。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Note(note)
範囲リスト内の各 Range のメモテキストを設定します。
const sheet = SpreadsheetApp.getActiveSheet(); const rangeList = sheet.getRangeList(['A:A', 'C:C']); rangeList.setNote('This is a note');
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
note | String | 設定するメモのテキスト。null 値を指定すると、メモが削除されます。 |
戻る
Range - チェーン用のこの範囲リスト。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Number Format(numberFormat)
範囲リスト内の各 Range の数値または日付の形式を設定します。
使用できる形式パターンについては、Sheets API の日付と数値の形式設定ガイドをご覧ください。
const sheet = SpreadsheetApp.getActiveSheet(); const rangeList = sheet.getRangeList(['A1:A10', 'C1:C10']); // Always show 3 decimal points for the specified ranges. rangeList.setNumberFormat('0.000');
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
number | String | 数値形式の文字列。 |
戻る
Range - チェーン用のこの範囲リスト。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Show Hyperlink(showHyperlink)
範囲リスト内の各 Range にハイパーリンクを表示するかどうかを設定します。
const sheet = SpreadsheetApp.getActiveSheet(); const rangeList = sheet.getRangeList(['A1:A10', 'C1:C10']); // Show hyperlinks for all the ranges. rangeList.setShowHyperlink(true);
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
show | Boolean | ハイパーリンクを表示するかどうか。 |
戻る
Range - チェーン用のこの範囲リスト。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Text Direction(direction)
範囲リスト内の各 Range のセルにテキストの方向を設定します。指定された方向が null の場合、方向が推測されて設定されます。
// Sets right-to-left text direction each range in the range list. const sheet = SpreadsheetApp.getActiveSheet(); const rangeList = sheet.getRangeList(['A1:A10', 'C1:C10']); rangeList.setTextDirection(SpreadsheetApp.TextDirection.RIGHT_TO_LEFT);
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
direction | Text | 目的のテキストの方向。null の場合、設定前に方向が推測されます。 |
戻る
Range - チェーン用のこの範囲リスト。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Text Rotation(degrees)
範囲リスト内の各 Range のセルにテキストの回転設定を設定します。入力は、標準のテキストの向きと目的の向きの間の角度に対応します。入力が 0 の場合は、テキストが標準の向きに設定されていることを示します。
左から右のテキスト方向の場合、正の角度は反時計回りになり、右から左の場合は時計回りになります。
// Sets the cells in the ranges A1:A10 and C1:C10 to have text rotated up 45 // degrees. const sheet = SpreadsheetApp.getActiveSheet(); const rangeList = sheet.getRangeList(['A1:A10', 'C1:C10']); rangeList.setTextRotation(45);
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
degrees | Integer | 標準の向きと目的の向きの間の目的の角度。左から右のテキストの場合、正の角度は反時計回りになります。 |
戻る
Range - チェーン用のこの範囲リスト。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Value(value)
範囲リスト内の各 Range の値を設定します。値は、数値、文字列、ブール値、または日付にできます。'=' で始まる場合は、数式として解釈されます。
const sheet = SpreadsheetApp.getActiveSheet(); // Set value of 100 to each range in the range list. const rangeList = sheet.getRangeList(['A:A', 'C:C']); rangeList.setValue(100);
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
value | Object | 範囲の値。 |
戻る
Range - チェーン用のこの範囲リスト。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Vertical Alignment(alignment)
範囲リスト内の各 Range の垂直方向の配置を設定します。配置オプションは 'top'、'middle'、'bottom' です。
// Sets the vertical alignment to middle for the list of ranges. const sheet = SpreadsheetApp.getActiveSheet(); const rangeList = sheet.getRangeList(['D4', 'B2:C4']); rangeList.setVerticalAlignment('middle');
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
alignment | String | 配置('top'、'middle'、'bottom' のいずれか)。null 値を指定すると、配置がリセットされます。 |
戻る
Range - チェーン用のこの範囲リスト。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Vertical Text(isVertical)
範囲リスト内の各 Range のセルでテキストを積み重ねるかどうかを設定します。テキストが縦に積み重ねられている場合、テキストの回転角度の設定は無視されます。
// Sets all cell's in ranges D4 and B2:D4 to have vertically stacked text. const sheet = SpreadsheetApp.getActiveSheet(); const rangeList = sheet.getRangeList(['D4', 'B2:C4']); rangeList.setVerticalText(true);
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
is | Boolean | テキストを積み重ねるかどうか。 |
戻る
Range - チェーン用のこの範囲リスト。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Wrap(isWrapEnabled)
範囲リスト内の各 Range のテキストの折り返しを設定します。折り返しが有効になっているセルは、コンテンツ全体が表示されるようにサイズが変更されます。折り返しが無効になっているセルには、サイズ変更や複数行への折り返しを行わずに、できるだけ多くの内容が表示されます。
// Enable text wrap for the list of ranges. const sheet = SpreadsheetApp.getActiveSheet(); const rangeList = sheet.getRangeList(['D4', 'B2:C4']); rangeList.setWrap(true);
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
is | Boolean | テキストを折り返すかどうか。 |
戻る
Range - チェーン用のこの範囲リスト。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Wrap Strategy(strategy)
範囲リスト内の各 Range のテキスト折り返し戦略を設定します。
// Sets the list of ranges to use the clip wrap strategy. const sheet = SpreadsheetApp.getActiveSheet(); const rangeList = sheet.getRangeList(['D4', 'B2:C4']); rangeList.setWrapStrategy(SpreadsheetApp.WrapStrategy.CLIP);
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
strategy | Wrap | 目的のラッピング戦略。 |
戻る
Range - チェーン用のこの範囲リスト。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
trim Whitespace()
この範囲リスト内のすべてのセルの空白文字(スペース、タブ、改行など)を削除します。各セルのテキストの先頭と末尾にあるすべての空白文字を削除し、残りの空白文字の連続を単一のスペースに置き換えます。
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0]; const range = sheet.getRange('A1:A4'); range.activate(); range.setValues([ ' preceding space', 'following space ', 'two middle spaces', ' =SUM(1,2)', ]); const rangeList = sheet.getRangeList(['A1', 'A2', 'A3', 'A4']); rangeList.trimWhitespace(); const values = range.getValues(); // Values are ['preceding space', 'following space', 'two middle spaces', // '=SUM(1,2)']
戻る
Range - チェーン用のこの範囲リスト。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
関連情報
uncheck()
範囲内のチェックボックスの状態を「オフ」に変更します。現在、構成されているオンまたはオフの値のいずれも含まれていない範囲内のセルは無視されます。
// Changes the state of cells which currently contain either the checked or // unchecked value configured in the ranges D4 and E6 to 'unchecked'. const rangeList = SpreadsheetApp.getActive().getRangeList(['D4', 'E6']); rangeList.uncheck();
戻る
Range - チェーン用のこの範囲リスト。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets