フィルタ条件のビルダー。フィルタに条件を追加するには、次の操作を行う必要があります。
Spreadsheetを使用して条件ビルダーを作成します。App.newFilterCriteria() - このクラスのメソッドを使用して、ビルダーに設定を追加します。
build()を使用して、指定した設定で条件を組み立てます。
一般的な使用例
シートの値を非表示にする
次のサンプルでは、シートの既存のフィルタを取得し、「hello」または「world」を含む列 C のセルを非表示にする条件を追加します。このサンプルの条件は、Grid シート(シートのデフォルト タイプ)のフィルタでのみ使用できます。const ss = SpreadsheetApp.getActiveSheet(); const filter = ss.getFilter(); const criteria = SpreadsheetApp.newFilterCriteria() .setHiddenValues(['hello', 'world']) .build(); filter.setColumnFilterCriteria(3, criteria);
値が必要なセルのみを表示する
次のサンプルでは、データベースに接続されたData Source シートにフィルタを追加し、[Category] 列の空でないセルのみを表示する条件を設定しています。// Gets the sheet named "Connected sheet," which is connected to a database. const sheet = SpreadsheetApp.getActiveSpreadsheet() .getSheetByName('Connected sheet') .asDataSourceSheet(); // Creates criteria that only shows non-empty cells. const criteria = SpreadsheetApp.newFilterCriteria().whenCellNotEmpty().build(); // Applies the criteria to the column named "Category." sheet.addFilter('Category', criteria);
メソッド
詳細なドキュメント
build()
条件ビルダーに追加した設定を使用してフィルタ条件を組み立てます。
// Gets the existing filter on the sheet. const ss = SpreadsheetApp.getActiveSheet(); const filter = ss.getFilter(); const criteria = SpreadsheetApp .newFilterCriteria() // Creates a criteria builder. .whenCellNotEmpty() // Adds settings to the builder. .build(); // Assembles the criteria. filter.setColumnFilterCriteria(2, criteria);
戻る
Filter - フィルタ条件の表現。
copy()
このフィルタ条件をコピーし、別のフィルタに適用できる条件ビルダーを作成します。
この方法は、任意のタイプのフィルタで使用できます。シートフィルタを使用している場合は、条件を別の列にコピーできます。
const ss = SpreadsheetApp.getActiveSheet(); const filter = ss.getFilter(); // Makes a copy of the filter criteria applied to column C. const criteria = filter.getColumnFilterCriteria(3).copy().build(); // Applies the copied criteria to column B. The copied criteria overwrites any // existing criteria on column B. filter.setColumnFilterCriteria(2, criteria);
戻る
Filter - このフィルタ条件に基づくフィルタ条件ビルダー。
get Criteria Type()
条件のブール型(CELL_EMPTY など)を返します。ブール条件のタイプについては、Boolean 列挙型をご覧ください。
この方法は、既存の条件を置き換えることなく、ブール値の条件基準をフィルタに追加する場合によく使用されます。
- 条件の引数を取得するには、
getを使用します。Criteria Values() - 条件タイプと条件値を使用してフィルタ条件を作成または変更するには、
withをご覧ください。Criteria(criteria, args)
この方法は、あらゆる種類のフィルタで使用できます。フィルタ条件がブール値の条件でない場合は、null を返します。
const ss = SpreadsheetApp.getActiveSheet(); // Gets the filter on the active sheet. const filter = ss.getFilter(); // Gets the criteria type and returns a string representing the criteria type // object. const criteriaType = filter.getColumnFilterCriteria(2).getCriteriaType().toString(); // Logs the criteria type. console.log(criteriaType);
戻る
Boolean - ブール値の条件のタイプ。条件がブール値の条件でない場合は null。
get Criteria Values()
ブール条件の引数の配列を返します。一部のブール値条件タイプには引数がなく、空の配列を返します(例: CELL_NOT_EMPTY)。
この方法は、既存の条件を置き換えることなく、ブール値の条件基準をフィルタに追加する場合によく使用されます。
- ブール値の条件タイプを取得するには、
getを使用します。Criteria Type() - 条件タイプと条件値を使用してフィルタ条件を作成または変更するには、
withをご覧ください。Criteria(criteria, args) この方法は、あらゆる種類のフィルタで使用できます。
const ss = SpreadsheetApp.getActiveSheet(); const filter = ss.getFilter(); // Gets the values of the boolean criteria and logs them. For example, if the // boolean condition is whenNumberGreaterThan(10), then the logged value is 10. const criteriaValues = filter.getColumnFilterCriteria(2).getCriteriaValues(); console.log(criteriaValues);
戻る
Object[]- ブール値の条件タイプに適した引数の配列。引数の数とその型は、Filterクラスの対応するCriteria Builder when...()メソッドと一致します。
get Hidden Values()
フィルタで非表示になっている値を返します。
この条件は、Grid シート(シートのデフォルトのタイプ)のフィルタで使用します。他のタイプのフィルタに対してこのメソッドを呼び出すと、null が返されます。
const ss = SpreadsheetApp.getActiveSheet(); const range = ss.getRange('A1:C20'); const filter = range.getFilter(); // Gets the filter criteria applied to column B, then gets the hidden values. const filterCriteria = filter.getColumnFilterCriteria(2).getHiddenValues(); // Logs the hidden values. console.log(filterCriteria);
戻る
String[] - フィルタで非表示にする値の配列。
get Visible Background Color()
フィルタ条件として使用される背景色を返します。この背景色のセルは表示されたままになります。
この条件は、Grid シート(シートのデフォルトのタイプ)のフィルタで使用します。他のタイプのフィルタに対してこのメソッドを呼び出すと、null が返されます。
const ss = SpreadsheetApp.getActiveSheet(); const range = ss.getRange('A1:C20'); // Logs the background color that column B is filtered by as a hexadecimal // string. const filter = range.getFilter(); const color = filter.getColumnFilterCriteria(2) .getVisibleBackgroundColor() .asRgbColor() .asHexString(); console.log(color);
戻る
Color|null - フィルタ条件として使用される背景色。
get Visible Foreground Color()
フィルタ条件として使用される前景色を返します。この前景色を持つセルは表示されたままになります。
この条件は、Grid シート(シートのデフォルトのタイプ)のフィルタで使用します。他のタイプのフィルタに対してこのメソッドを呼び出すと、null が返されます。
const ss = SpreadsheetApp.getActiveSheet(); const range = ss.getRange('A1:C20'); // Logs the foreground color that column B is filtered by as a hexadecimal // string. const filter = range.getFilter(); const color = filter.getColumnFilterCriteria(2) .getVisibleForegroundColor() .asRgbColor() .asHexString(); console.log(color);
戻る
Color|null - フィルタ条件として使用される前景色。
get Visible Values()
ピボット テーブルのフィルタに表示される値を返します。
この条件は、データベースに接続されていないピボット テーブルのフィルタにのみ適用されます。他のタイプのフィルタの場合は、空の配列を返します。
const ss = SpreadsheetApp.getActiveSheet(); // Gets the first pivot table on the sheet, then gets the visible values of its // first filter. const pivotTable = ss.getPivotTables()[0]; const pivotFilterValues = pivotTable.getFilters()[0].getFilterCriteria().getVisibleValues(); // Logs the visible values. console.log(pivotFilterValues);
戻る
String[] - ピボット テーブルのフィルタに表示される値の配列。
set Hidden Values(values)
非表示にする値を設定します。表示されている値と非表示の値がすべてクリアされます。
この条件は、Grid シート(シートのデフォルトのタイプ)のフィルタでのみ使用できます。
// Gets the existing filter on the range. const ss = SpreadsheetApp.getActiveSheet(); const range = ss.getRange('A1:C20'); const filter = range.getFilter(); // Sets the values to hide and applies the criteria to column C. const criteria = SpreadsheetApp.newFilterCriteria() .setHiddenValues(['Hello', 'World']) .build(); filter.setColumnFilterCriteria(3, criteria);
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
values | String[] | 非表示にする値のリスト。 |
戻る
Filter - チェーン用のこのビルダー。
例外
Error - 値のいずれかが null の場合。
set Visible Background Color(visibleBackgroundColor)
フィルタ条件として使用される背景色を設定します。この背景色のセルは表示されたままになります。背景色フィルタ条件を設定すると、このビルダーから現在の色フィルタ条件が削除されます。
この条件は、Grid シート(シートのデフォルトのタイプ)のフィルタでのみ使用できます。
// Gets the existing filter on the sheet. const ss = SpreadsheetApp.getActiveSheet(); const filter = ss.getFilter(); // Creates criteria that filters by background color and sets it to column B. const color = SpreadsheetApp.newColor().setRgbColor('#185ABC').build(); const criteria = SpreadsheetApp.newFilterCriteria().setVisibleBackgroundColor(color).build(); filter.setColumnFilterCriteria(2, criteria);
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
visible | Color | 設定する背景色。色は RGB 形式で指定する必要があります。このメソッドはテーマの色をサポートしていません。 |
戻る
Filter - チェーン用のこのビルダー。
set Visible Foreground Color(visibleForegroundColor)
フィルタ条件として使用される前景色を設定します。この前景色を持つセルは表示されたままになります。前景色フィルタ条件を設定すると、このビルダーから現在の色フィルタ条件が削除されます。
この条件は、Grid シート(シートのデフォルトのタイプ)のフィルタでのみ使用できます。
// Gets the existing filter on the sheet. const ss = SpreadsheetApp.getActiveSheet(); const filter = ss.getFilter(); // Creates criteria that filters by foreground color and sets it to column B. const color = SpreadsheetApp.newColor().setRgbColor('#185ABC').build(); const criteria = SpreadsheetApp.newFilterCriteria().setVisibleForegroundColor(color).build(); filter.setColumnFilterCriteria(2, criteria);
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
visible | Color | 設定する前景色。色は RGB 形式で指定する必要があります。このメソッドはテーマの色をサポートしていません。 |
戻る
Filter - チェーン用のこのビルダー。
set Visible Values(values)
ピボット テーブルに表示する値を設定します。表示されている値と非表示の値がすべてクリアされます。
この条件は、データベースに接続されていないピボット テーブルのフィルタでのみ使用できます。
// Gets the active sheet. const ss = SpreadsheetApp.getActiveSheet(); // Gets the first pivot table on the sheet and adds a filter to it that // sets the visible values to "Northeast" and "Southwest." const pivotTable = ss.getPivotTables()[0]; const criteria = SpreadsheetApp.newFilterCriteria() .setVisibleValues(['Northeast', 'Southwest']) .build(); pivotTable.addFilter(2, criteria);
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
values | String[] | 表示する値のリスト。 |
戻る
Filter - チェーン用のこのビルダー。
例外
Error - 値のいずれかが null の場合。
when Cell Empty()
フィルタ条件を設定して、空のセルを表示します。
この条件は、あらゆる種類のフィルタで使用できます。
// Gets the existing filter on the range. const ss = SpreadsheetApp.getActiveSheet(); const range = ss.getRange('A1:C20'); const filter = range.getFilter(); // Sets criteria to column B that only shows empty cells. const criteria = SpreadsheetApp.newFilterCriteria().whenCellEmpty().build(); filter.setColumnFilterCriteria(2, criteria);
戻る
Filter - チェーン用のこのビルダー。
when Cell Not Empty()
フィルタ条件を設定して、空でないセルを表示します。
この条件は、あらゆる種類のフィルタで使用できます。
// Gets the existing filter on the range. const ss = SpreadsheetApp.getActiveSheet(); const range = ss.getRange('A1:C20'); const filter = range.getFilter(); // Sets criteria to column B that only shows cells that aren't empty. const criteria = SpreadsheetApp.newFilterCriteria().whenCellNotEmpty().build(); filter.setColumnFilterCriteria(2, criteria);
戻る
Filter - チェーン用のこのビルダー。
when Date After(date)
指定した日付より後の日付を含むセルを表示するフィルタ条件を設定します。
この条件は、あらゆる種類のフィルタで使用できます。この条件をデータベースに接続されたデータで使用する場合、フィルタリングする列のデータ型は日付である必要があります。データがデータベースに接続されていない場合、フィルタリングする列のデータ型は日付である必要はありませんが、日付でない場合は予期しない結果になる可能性があります。
// Gets the existing filter on the range. const ss = SpreadsheetApp.getActiveSheet(); const range = ss.getRange('A1:C20'); const filter = range.getFilter(); // Creates criteria that only shows cells with dates after June 1, 2022 // and sets it to column A. const date = new Date('June 1, 2022'); const criteria = SpreadsheetApp.newFilterCriteria().whenDateAfter(date).build(); filter.setColumnFilterCriteria(1, criteria);
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
date | Date | 非表示にする最新の日付。 |
戻る
Filter - チェーン用のこのビルダー。
when Date After(date)
指定した相対日付より後の日付を含むセルを表示するフィルタ条件を設定します。相対日付オプションを表示するには、列挙型 Relative をご覧ください。
この条件は、あらゆる種類のフィルタで使用できます。この条件をデータベースに接続されたデータで使用する場合、フィルタリングする列のデータ型は日付である必要があります。データがデータベースに接続されていない場合、フィルタリングする列のデータ型は日付である必要はありませんが、日付でない場合は予期しない結果になる可能性があります。
// Gets the existing filter on the range. const ss = SpreadsheetApp.getActiveSheet(); const range = ss.getRange('A1:C20'); const filter = range.getFilter(); // Creates criteria that only shows cells with dates after today's date // and sets it to column A. const criteria = SpreadsheetApp.newFilterCriteria() .whenDateAfter(SpreadsheetApp.RelativeDate.TODAY) .build(); filter.setColumnFilterCriteria(1, criteria);
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
date | Relative | 最新の相対日付。 |
戻る
Filter - チェーン用のこのビルダー。
when Date Before(date)
指定した日付より前の日付を含むセルを表示するフィルタ条件を設定します。
この条件は、あらゆる種類のフィルタで使用できます。この条件をデータベースに接続されたデータで使用する場合、フィルタリングする列のデータ型は日付である必要があります。データがデータベースに接続されていない場合、フィルタリングする列のデータ型は日付である必要はありませんが、日付でない場合は予期しない結果になる可能性があります。
// Gets the existing filter on the range. const ss = SpreadsheetApp.getActiveSheet(); const range = ss.getRange('A1:C20'); const filter = range.getFilter(); // Creates criteria that only shows cells with dates before June 1, 2022 // and sets it to column A. const date = new Date('June 1, 2022'); const criteria = SpreadsheetApp.newFilterCriteria().whenDateBefore(date).build(); filter.setColumnFilterCriteria(1, criteria);
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
date | Date | 非表示にする最も古い日付。 |
戻る
Filter - チェーン用のこのビルダー。
when Date Before(date)
指定された相対日付より前の日付を含むセルを表示するフィルタ条件を設定します。相対日付オプションを表示するには、列挙型 Relative をご覧ください。
この条件は、あらゆる種類のフィルタで使用できます。この条件をデータベースに接続されたデータで使用する場合、フィルタリングする列のデータ型は日付である必要があります。データがデータベースに接続されていない場合、フィルタリングする列のデータ型は日付である必要はありませんが、日付でない場合は予期しない結果になる可能性があります。
// Gets the existing filter on the range. const ss = SpreadsheetApp.getActiveSheet(); const range = ss.getRange('A1:C20'); const filter = range.getFilter(); // Creates criteria that only shows cells with dates before today's date // and sets it to column A. const criteria = SpreadsheetApp.newFilterCriteria() .whenDateBefore(SpreadsheetApp.RelativeDate.TODAY) .build(); filter.setColumnFilterCriteria(1, criteria);
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
date | Relative | 非表示にする最も古い相対日付。 |
戻る
Filter - チェーン用のこのビルダー。
when Date Equal To(date)
指定した日付と等しい日付を含むセルを表示するフィルタ条件を設定します。
この条件は、あらゆる種類のフィルタで使用できます。この条件をデータベースに接続されたデータで使用する場合、フィルタリングする列のデータ型は日付である必要があります。データがデータベースに接続されていない場合、フィルタリングする列のデータ型は日付である必要はありませんが、日付でない場合は予期しない結果になる可能性があります。
// Gets the existing filter on the range. const ss = SpreadsheetApp.getActiveSheet(); const range = ss.getRange('A1:C20'); const filter = range.getFilter(); // Creates criteria that only shows cells with dates equal to June 1, 2022 // and sets it to column A. const date = new Date('June 1, 2022'); const criteria = SpreadsheetApp.newFilterCriteria().whenDateEqualTo(date).build(); filter.setColumnFilterCriteria(1, criteria);
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
date | Date | セル値が一致する必要がある日付。 |
戻る
Filter - チェーン用のこのビルダー。
when Date Equal To(date)
指定された相対日付と等しい日付を含むセルを表示するフィルタ条件を設定します。相対日付オプションを表示するには、列挙型 Relative をご覧ください。
この条件は、あらゆる種類のフィルタで使用できます。この条件をデータベースに接続されたデータで使用する場合、フィルタリングする列のデータ型は日付である必要があります。データがデータベースに接続されていない場合、フィルタリングする列のデータ型は日付である必要はありませんが、日付でない場合は予期しない結果になる可能性があります。
// Gets the existing filter on the range. const ss = SpreadsheetApp.getActiveSheet(); const range = ss.getRange('A1:C20'); const filter = range.getFilter(); // Creates criteria that only shows cells with dates that fall within the past // month and sets it to column A. const criteria = SpreadsheetApp.newFilterCriteria() .whenDateEqualTo(SpreadsheetApp.RelativeDate.PAST_MONTH) .build(); filter.setColumnFilterCriteria(1, criteria);
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
date | Relative | セル値が一致する必要がある相対日付。 |
戻る
Filter - チェーン用のこのビルダー。
when Date Equal To Any(dates)
指定された日付のいずれかに等しい日付を含むセルを表示するようにフィルタ条件を設定します。
この条件は、データベースに接続されているデータでのみ使用できます。たとえば、この条件を Data シート、データベースに接続されているシート、Data シートから作成されたピボット テーブルである Data のフィルタで使用します。
// Gets the sheet that's connected to a database. const ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Data Sheet'); const dataSheet = ss.asDataSourceSheet(); // Adds criteria to the "date" column that shows cells with any of the below // dates. const date1 = new Date('June 1, 2022'); const date2 = new Date('June 2, 2022'); const date3 = new Date('June 3, 2022'); const criteria = SpreadsheetApp.newFilterCriteria() .whenDateEqualToAny([date1, date2, date3]) .build(); dataSheet.addFilter('date', criteria);
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
dates | Date[] | 表示する日付。 |
戻る
Filter - チェーン用のこのビルダー。
when Date Not Equal To(date)
指定した日付と等しくないセルを表示するようにフィルタ条件を設定します。
この条件は、データベースに接続されているデータでのみ使用できます。たとえば、この条件を Data シート、データベースに接続されているシート、Data シートから作成されたピボット テーブルである Data のフィルタで使用します。
フィルタリングする列のデータ型は日付である必要があります。
// Gets a pivot table that's connected to a database. const ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Pivot Table Sheet'); const dataPivotTable = ss.getDataSourcePivotTables()[0]; // Creates criteria that only shows cells that don't equal June 16, 2022 // and sets it to the "date" column. const date = new Date('June 16, 2022'); const criteria = SpreadsheetApp.newFilterCriteria().whenDateNotEqualTo(date).build(); dataPivotTable.addFilter('date', criteria);
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
date | Date | 非表示にする日付。 |
戻る
Filter - チェーン用のこのビルダー。
when Date Not Equal To Any(dates)
指定された日付のいずれとも等しくない日付を含むセルを表示するようにフィルタ条件を設定します。
この条件は、データベースに接続されているデータでのみ使用できます。たとえば、この条件を Data シート、データベースに接続されているシート、Data シートから作成されたピボット テーブルである Data のフィルタで使用します。
// Gets the sheet that's connected to a database. const ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Data Sheet'); const dataSheet = ss.asDataSourceSheet(); // Adds criteria to the "date" column that hides cells with any of the below // dates. const date1 = new Date('June 1, 2022'); const date2 = new Date('June 2, 2022'); const date3 = new Date('June 3, 2022'); const criteria = SpreadsheetApp.newFilterCriteria() .whenDateNotEqualToAny([date1, date2, date3]) .build(); dataSheet.addFilter('date', criteria);
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
dates | Date[] | 非表示にする日付。 |
戻る
Filter - チェーン用のこのビルダー。
when Formula Satisfied(formula)
指定された数式(=B:B<C:C など)が true と評価されるセルを表示するようにフィルタ条件を設定します。
この条件は、データベースに接続されていないデータのフィルタリングにのみ使用できます。
// Gets the existing filter on the sheet. const ss = SpreadsheetApp.getActiveSheet(); const filter = ss.getFilter(); // Creates criteria that shows the rows where the value in column B is less than // the value in column C and sets it to column A. const formula = '=B:B<C:C'; const criteria = SpreadsheetApp.newFilterCriteria().whenFormulaSatisfied(formula).build(); filter.setColumnFilterCriteria(1, criteria);
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
formula | String | 入力が有効な場合に true と評価されるカスタム数式。 |
戻る
Filter - チェーン用のこのビルダー。
when Number Between(start, end)
フィルタ条件を設定して、指定した 2 つの数値の範囲内にある数値を含むセルを表示します。
この条件は、あらゆる種類のフィルタで使用できます。この条件をデータベースに接続されたデータで使用する場合、フィルタリングする列のデータ型は数値である必要があります。データがデータベースに接続されていない場合、フィルタリングする列のデータ型は数値である必要はありませんが、数値でない場合は予期しない結果になることがあります。
// Gets the existing filter on the sheet. const ss = SpreadsheetApp.getActiveSheet(); const filter = ss.getFilter(); // Creates criteria that only shows cells with numbers that fall between 1-25, // inclusively, and sets it to column A. const criteria = SpreadsheetApp.newFilterCriteria().whenNumberBetween(1, 25).build(); filter.setColumnFilterCriteria(1, criteria);
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
start | Number | 表示する最小値。 |
end | Number | 表示する最大数。 |
戻る
Filter - チェーン用のこのビルダー。
when Number Equal To(number)
指定した数値と等しい数値を含むセルを表示するフィルタ条件を設定します。
この条件は、あらゆる種類のフィルタで使用できます。この条件をデータベースに接続されたデータで使用する場合、フィルタリングする列のデータ型は数値である必要があります。データがデータベースに接続されていない場合、フィルタリングする列のデータ型は数値である必要はありませんが、数値でない場合は予期しない結果になることがあります。
// Gets the existing filter on the sheet. const ss = SpreadsheetApp.getActiveSheet(); const filter = ss.getFilter(); // Creates criteria that only shows cells that are equal to 25 and sets it to // column B. const criteria = SpreadsheetApp.newFilterCriteria().whenNumberEqualTo(25).build(); filter.setColumnFilterCriteria(2, criteria);
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
number | Number | 表示する数値。 |
戻る
Filter - チェーン用のこのビルダー。
when Number Equal To Any(numbers)
指定された数値のいずれかに等しい数値を含むセルを表示するようにフィルタ条件を設定します。
この条件は、データベースに接続されているデータでのみ使用できます。たとえば、この条件を Data シート、データベースに接続されているシート、Data シートから作成されたピボット テーブルである Data のフィルタで使用します。
// Gets the sheet that's connected to a database. const ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Data Sheet'); const dataSheet = ss.asDataSourceSheet(); // Adds criteria to the "amount" column that only shows cells with the number // 10, 20, or 30. const criteria = SpreadsheetApp.newFilterCriteria() .whenNumberEqualToAny([10, 20, 30]) .build(); dataSheet.addFilter('amount', criteria);
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
numbers | Number[] | 表示する数値。 |
戻る
Filter - チェーン用のこのビルダー。
when Number Greater Than(number)
指定した数値より大きい数値を含むセルを表示するようにフィルタ条件を設定します。
この条件は、あらゆる種類のフィルタで使用できます。この条件をデータベースに接続されたデータで使用する場合、フィルタリングする列のデータ型は数値である必要があります。データがデータベースに接続されていない場合、フィルタリングする列のデータ型は数値である必要はありませんが、数値でない場合は予期しない結果になることがあります。
// Gets the existing filter on the sheet. const ss = SpreadsheetApp.getActiveSheet(); const filter = ss.getFilter(); // Creates criteria that shows cells greater than 10 and sets it to column B. const criteria = SpreadsheetApp.newFilterCriteria().whenNumberGreaterThan(10).build(); filter.setColumnFilterCriteria(2, criteria);
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
number | Number | 非表示にする最大数。 |
戻る
Filter - チェーン用のこのビルダー。
when Number Greater Than Or Equal To(number)
指定した数値以上の数値を含むセルを表示するフィルタ条件を設定します。
この条件は、あらゆる種類のフィルタで使用できます。この条件をデータベースに接続されたデータで使用する場合、フィルタリングする列のデータ型は数値である必要があります。データがデータベースに接続されていない場合、フィルタリングする列のデータ型は数値である必要はありませんが、数値でない場合は予期しない結果になることがあります。
// Gets the existing filter on the sheet. const ss = SpreadsheetApp.getActiveSheet(); const filter = ss.getFilter(); // Creates criteria that shows cells greater than or equal to 10 and sets it to // column B. const criteria = SpreadsheetApp.newFilterCriteria() .whenNumberGreaterThanOrEqualTo(10) .build(); filter.setColumnFilterCriteria(2, criteria);
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
number | Number | 表示する最小値。 |
戻る
Filter - チェーン用のこのビルダー。
when Number Less Than(number)
指定した数値より小さい数値を含むセルを表示するフィルタ条件を設定します。
この条件は、あらゆる種類のフィルタで使用できます。この条件をデータベースに接続されたデータで使用する場合、フィルタリングする列のデータ型は数値である必要があります。データがデータベースに接続されていない場合、フィルタリングする列のデータ型は数値である必要はありませんが、数値でない場合は予期しない結果になることがあります。
// Gets the existing filter on the sheet. const ss = SpreadsheetApp.getActiveSheet(); const filter = ss.getFilter(); // Creates criteria that shows cells less than 10 and sets it to column B. const criteria = SpreadsheetApp.newFilterCriteria().whenNumberLessThan(10).build(); filter.setColumnFilterCriteria(2, criteria);
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
number | Number | 非表示にする最小の数値。 |
戻る
Filter - チェーン用のこのビルダー。
when Number Less Than Or Equal To(number)
指定した数値以下の数値を含むセルを表示するようにフィルタ条件を設定します。
この条件は、あらゆる種類のフィルタで使用できます。この条件をデータベースに接続されたデータで使用する場合、フィルタリングする列のデータ型は数値である必要があります。データがデータベースに接続されていない場合、フィルタリングする列のデータ型は数値である必要はありませんが、数値でない場合は予期しない結果になることがあります。
// Gets the existing filter on the sheet. const ss = SpreadsheetApp.getActiveSheet(); const filter = ss.getFilter(); // Creates criteria that shows cells less than or equal to 10 and sets it to // column B. const criteria = SpreadsheetApp.newFilterCriteria().whenNumberLessThanOrEqualTo(10).build(); filter.setColumnFilterCriteria(2, criteria);
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
number | Number | 表示する最大数。 |
戻る
Filter - チェーン用のこのビルダー。
when Number Not Between(start, end)
2 つの指定された数値の範囲外の数値を含むセルを表示するフィルタ条件を設定します。
この条件は、あらゆる種類のフィルタで使用できます。この条件をデータベースに接続されたデータで使用する場合、フィルタリングする列のデータ型は数値である必要があります。データがデータベースに接続されていない場合、フィルタリングする列のデータ型は数値である必要はありませんが、数値でない場合は予期しない結果になることがあります。
// Gets the existing filter on the sheet. const ss = SpreadsheetApp.getActiveSheet(); const filter = ss.getFilter(); // Creates criteria that hides cells with numbers that fall between 1-25, // inclusively, and sets it to column B. const criteria = SpreadsheetApp.newFilterCriteria().whenNumberNotBetween(1, 25).build(); filter.setColumnFilterCriteria(2, criteria);
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
start | Number | 最小の数字を非表示にします。 |
end | Number | 非表示にする最大数。 |
戻る
Filter - チェーン用のこのビルダー。
when Number Not Equal To(number)
指定した数値と等しくない数値を含むセルを表示するフィルタ条件を設定します。
この条件は、あらゆる種類のフィルタで使用できます。この条件をデータベースに接続されたデータで使用する場合、フィルタリングする列のデータ型は数値である必要があります。データがデータベースに接続されていない場合、フィルタリングする列のデータ型は数値である必要はありませんが、数値でない場合は予期しない結果になることがあります。
// Gets the existing filter on the sheet. const ss = SpreadsheetApp.getActiveSheet(); const filter = ss.getFilter(); // Creates criteria that hides cells that are equal to 25 and sets it to column // B. const criteria = SpreadsheetApp.newFilterCriteria().whenNumberNotEqualTo(25).build(); filter.setColumnFilterCriteria(2, criteria);
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
number | Number | 非表示にする番号。 |
戻る
Filter - チェーン用のこのビルダー。
when Number Not Equal To Any(numbers)
指定された数値のいずれにも等しくない数値を含むセルを表示するようにフィルタ条件を設定します。
この条件は、データベースに接続されているデータでのみ使用できます。たとえば、この条件を Data シート、データベースに接続されているシート、Data シートから作成されたピボット テーブルである Data のフィルタで使用します。
// Gets the sheet that's connected to a database. const ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Data Sheet'); const dataSheet = ss.asDataSourceSheet(); // Adds criteria to the "amount" column that hides cells with the number 10, 20, // or 30. const criteria = SpreadsheetApp.newFilterCriteria() .whenNumberNotEqualToAny([10, 20, 30]) .build(); dataSheet.addFilter('amount', criteria);
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
numbers | Number[] | 非表示にする数値。 |
戻る
Filter - チェーン用のこのビルダー。
when Text Contains(text)
指定したテキストを含むテキストを含むセルを表示するようにフィルタ条件を設定します。テキストでは大文字と小文字は区別されません。
この条件は、あらゆる種類のフィルタで使用できます。
// Gets the existing filter on the sheet. const ss = SpreadsheetApp.getActiveSheet(); const filter = ss.getFilter(); // Creates criteria that shows cells that contain "Northwest" and sets it to // column B. const criteria = SpreadsheetApp.newFilterCriteria().whenTextContains('Northwest').build(); filter.setColumnFilterCriteria(2, criteria);
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
text | String | セルに含める必要があるテキスト。 |
戻る
Filter - チェーン用のこのビルダー。
when Text Does Not Contain(text)
指定したテキストを含まないテキストを含むセルを表示するようにフィルタ条件を設定します。テキストでは大文字と小文字は区別されません。
この条件は、あらゆる種類のフィルタで使用できます。
// Gets the existing filter on the sheet. const ss = SpreadsheetApp.getActiveSheet(); const filter = ss.getFilter(); // Creates criteria that hides cells that contain "Northwest" and sets it to // column B. const criteria = SpreadsheetApp.newFilterCriteria() .whenTextDoesNotContain('Northwest') .build(); filter.setColumnFilterCriteria(2, criteria);
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
text | String | セルに含めてはならないテキスト。 |
戻る
Filter - チェーン用のこのビルダー。
when Text Ends With(text)
指定したテキストで終わるテキストを含むセルを表示するようにフィルタ条件を設定します。テキストでは大文字と小文字は区別されません。
この条件は、あらゆる種類のフィルタで使用できます。
// Gets the existing filter on the sheet. const ss = SpreadsheetApp.getActiveSheet(); const filter = ss.getFilter(); // Creates criteria that shows cells with text that ends with "est" and sets it // to column B. const criteria = SpreadsheetApp.newFilterCriteria().whenTextEndsWith('est').build(); filter.setColumnFilterCriteria(2, criteria);
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
text | String | セルのテキストの末尾に含める必要があるテキスト。 |
戻る
Filter - チェーン用のこのビルダー。
when Text Equal To(text)
指定したテキストと等しいテキストを含むセルを表示するようにフィルタ条件を設定します。テキストでは大文字と小文字は区別されません。
この条件は、あらゆる種類のフィルタで使用できます。
// Gets the existing filter on the sheet. const ss = SpreadsheetApp.getActiveSheet(); const filter = ss.getFilter(); // Creates criteria that shows cells with text that equals "hello" and sets it // to column B. const criteria = SpreadsheetApp.newFilterCriteria().whenTextEqualTo('hello').build(); filter.setColumnFilterCriteria(2, criteria);
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
text | String | セルのテキストが一致する必要があるテキスト。 |
戻る
Filter - チェーン用のこのビルダー。
when Text Equal To Any(texts)
指定されたテキスト値のいずれかに等しいテキストを含むセルを表示するようにフィルタ条件を設定します。テキストでは大文字と小文字は区別されません。
この条件は、データベースに接続されているデータでのみ使用できます。たとえば、この条件を Data シート、データベースに接続されているシート、Data シートから作成されたピボット テーブルである Data のフィルタで使用します。
// Gets the sheet that's connected to a database. const ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Data Sheet'); const dataSheet = ss.asDataSourceSheet(); // Adds criteria to the "category" column that shows cells with the text "tech" // or "business." const criteria = SpreadsheetApp.newFilterCriteria() .whenTextEqualToAny(['tech', 'business']) .build(); dataSheet.addFilter('category', criteria);
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
texts | String[] | セルが等しくなければならないテキスト値。 |
戻る
Filter - チェーン用のこのビルダー。
when Text Not Equal To(text)
指定したテキストと等しくないテキストを含むセルを表示するようにフィルタ条件を設定します。テキストでは大文字と小文字は区別されません。
この条件は、データベースに接続されているデータでのみ使用できます。たとえば、この条件を Data シート、データベースに接続されているシート、Data シートから作成されたピボット テーブルである Data のフィルタで使用します。
// Gets the sheet that's connected to a database. const ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Data Sheet'); const dataSheet = ss.asDataSourceSheet(); // Adds criteria to the "category" column that hides cells with text equal to // "tech." const criteria = SpreadsheetApp.newFilterCriteria().whenTextNotEqualTo('tech').build(); dataSheet.addFilter('category', criteria);
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
text | String | セルのテキストが等しくないテキスト。 |
戻る
Filter - チェーン用のこのビルダー。
when Text Not Equal To Any(texts)
指定された値のいずれにも等しくないテキストを含むセルを表示するようにフィルタ条件を設定します。テキストでは大文字と小文字は区別されません。
この条件は、データベースに接続されているデータでのみ使用できます。たとえば、この条件を Data シート、データベースに接続されているシート、Data シートから作成されたピボット テーブルである Data のフィルタで使用します。
// Gets the sheet that's connected to a database. const ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Data Sheet'); const dataSheet = ss.asDataSourceSheet(); // Adds criteria to the "category" column that hides cells with the text "tech" // or "business." const criteria = SpreadsheetApp.newFilterCriteria() .whenTextNotEqualToAny(['tech', 'business']) .build(); dataSheet.addFilter('category', criteria);
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
texts | String[] | セルが等しくないテキスト値。 |
戻る
Filter - チェーン用のこのビルダー。
when Text Starts With(text)
指定したテキストで始まるテキストを含むセルを表示するようにフィルタ条件を設定します。テキストでは大文字と小文字は区別されません。
この条件は、あらゆる種類のフィルタで使用できます。
// Gets the existing filter on the sheet. const ss = SpreadsheetApp.getActiveSheet(); const filter = ss.getFilter(); // Creates criteria that shows cells with text that starts with "pre" and sets // it to column B. const criteria = SpreadsheetApp.newFilterCriteria().whenTextStartsWith('pre').build(); filter.setColumnFilterCriteria(2, criteria);
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
text | String | セルのテキストの先頭に含める必要があるテキスト。 |
戻る
Filter - チェーン用のこのビルダー。
with Criteria(criteria, args)
フィルタ条件を、CELL_EMPTY や NUMBER_GREATER_THAN などの Boolean 値で定義されたブール条件に設定します。既存の条件からブール条件をコピーするには、既存の条件の get と get を使用して、このメソッドのパラメータを定義します。
この条件はあらゆるタイプのフィルタで使用できますが、一部の Boolean はすべてのフィルタに適用できるわけではありません。
// Builds a filter criteria that is based on existing boolean conditions from // another criteria. Gets the existing filter on the sheet. const ss = SpreadsheetApp.getActiveSheet(); const filter = ss.getFilter(); // Gets the existing boolean conditions applied to Column B and adds criteria to // column C that has the same boolean conditions and additional criteria that // hides the value, "Northwest." const filterCriteria = filter.getColumnFilterCriteria(2); const criteria = SpreadsheetApp.newFilterCriteria() .withCriteria( filterCriteria.getCriteriaType(), filterCriteria.getCriteriaValues(), ) .setHiddenValues(['Northwest']) .build(); filter.setColumnFilterCriteria(3, criteria);
パラメータ
| 名前 | 型 | 説明 |
|---|---|---|
criteria | Boolean | ブール条件のタイプ。 |
args | Object[] | 条件タイプに適した引数の配列。引数の数とその型は、上記の対応する when...() メソッドと一致します。 |
戻る
Filter - チェーン用のこのビルダー。