Excel.AutoFilter class
AutoFilter オブジェクトを表します。 オートフィルターは、Excel 列の値をセルの内容に基づいて特定のフィルターに変換します。
- Extends
プロパティ
| context | オブジェクトに関連付けられている要求コンテキスト。 これにより、アドインのプロセスが Office ホスト アプリケーションのプロセスに接続されます。 |
| criteria | オートフィルターが適用された範囲のすべてのフィルター条件を保持する配列です。 |
| enabled | オートフィルターを有効にするかどうかを指定します。 |
| is |
オートフィルターにフィルター条件があるかどうかを指定します。 |
メソッド
| apply(range, column |
範囲にオートフィルターを適用します。 列インデックスやフィルター条件が指定されている場合、列にフィルターを適用します。 |
| clear |
オートフィルターの列フィルター条件をクリアします。 |
| clear |
オートフィルターのフィルター条件と並べ替え状態をクリアします。 |
| get |
オートフィルターが適用される範囲を表す |
| get |
オートフィルターが適用される範囲を表す |
| load(options) | オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、 |
| load(property |
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、 |
| load(property |
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、 |
| reapply() | 現在範囲にある指定されたオートフィルター オブジェクトを適用します。 |
| remove() | 範囲の AutoFilter を削除します。 |
| toJSON() | API オブジェクトが |
プロパティの詳細
context
オブジェクトに関連付けられている要求コンテキスト。 これにより、アドインのプロセスが Office ホスト アプリケーションのプロセスに接続されます。
context: RequestContext;
プロパティ値
criteria
オートフィルターが適用された範囲のすべてのフィルター条件を保持する配列です。
readonly criteria: Excel.FilterCriteria[];
プロパティ値
注釈
enabled
isDataFiltered
オートフィルターにフィルター条件があるかどうかを指定します。
readonly isDataFiltered: boolean;
プロパティ値
boolean
注釈
メソッドの詳細
apply(range, columnIndex, criteria)
範囲にオートフィルターを適用します。 列インデックスやフィルター条件が指定されている場合、列にフィルターを適用します。
apply(range: Range | string, columnIndex?: number, criteria?: Excel.FilterCriteria): void;
パラメーター
- range
-
Excel.Range | string
オートフィルターが適用される範囲。
- columnIndex
-
number
オートフィルターが適用される 0 から始まる列インデックス。
- criteria
- Excel.FilterCriteria
フィルター条件。
返品
void
注釈
例
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/worksheet-auto-filter.yaml
// This function adds a percentage AutoFilter to the active worksheet
// and applies the filter to a column of the used range.
await Excel.run(async (context) => {
// Retrieve the active worksheet and the used range on that worksheet.
const sheet = context.workbook.worksheets.getActiveWorksheet();
const farmData = sheet.getUsedRange();
// Add a filter that will only show the rows with the top 50% of values in column 3.
sheet.autoFilter.apply(farmData, 3, {
criterion1: "50",
filterOn: Excel.FilterOn.topPercent
});
await context.sync();
});
clearColumnCriteria(columnIndex)
オートフィルターの列フィルター条件をクリアします。
clearColumnCriteria(columnIndex: number): void;
パラメーター
- columnIndex
-
number
ゼロ ベースの列インデックス。クリアする必要がある列フィルターを表します。 インデックス値がサポートされていない場合 (たとえば、値が負の数値の場合や、値が範囲内の使用可能な列の数より大きい場合)、 InvalidArgument エラーがスローされます。
返品
void
注釈
例
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/worksheet-auto-filter.yaml
// This function clears the AutoFilter setting from one column.
await Excel.run(async (context) => {
// Retrieve the active worksheet.
const sheet = context.workbook.worksheets.getActiveWorksheet();
// Clear the filter from only column 3.
sheet.autoFilter.clearColumnCriteria(3);
await context.sync();
});
clearCriteria()
getRange()
オートフィルターが適用される範囲を表す Range オブジェクトを返します。
getRange(): Excel.Range;
返品
注釈
getRangeOrNullObject()
オートフィルターが適用される範囲を表す Range オブジェクトを返します。 オートフィルターに関連付けられている Range オブジェクトがない場合、このメソッドは isNullObject プロパティが true に設定されたオブジェクトを返します。 詳細については、「 *OrNullObject のメソッドとプロパティ」を参照してください。
getRangeOrNullObject(): Excel.Range;
返品
注釈
load(options)
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。
load(options?: Excel.Interfaces.AutoFilterLoadOptions): Excel.AutoFilter;
パラメーター
読み込むオブジェクトのプロパティのオプションを指定します。
返品
load(propertyNames)
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。
load(propertyNames?: string | string[]): Excel.AutoFilter;
パラメーター
- propertyNames
-
string | string[]
読み込むプロパティを指定するコンマ区切りの文字列または文字列の配列。
返品
load(propertyNamesAndPaths)
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。
load(propertyNamesAndPaths?: {
select?: string;
expand?: string;
}): Excel.AutoFilter;
パラメーター
- propertyNamesAndPaths
-
{ select?: string; expand?: string; }
propertyNamesAndPaths.select は読み込むプロパティを指定するコンマ区切りの文字列であり、 propertyNamesAndPaths.expand は読み込むナビゲーションのプロパティを指定するコンマ区切りの文字列です。
返品
reapply()
現在範囲にある指定されたオートフィルター オブジェクトを適用します。
reapply(): void;
返品
void
注釈
例
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/worksheet-auto-filter.yaml
// This function refreshes the AutoFilter to ensure that changes are captured.
await Excel.run(async (context) => {
// Retrieve the active worksheet.
const sheet = context.workbook.worksheets.getActiveWorksheet();
// Reapply the filter to capture changes.
sheet.autoFilter.reapply();
await context.sync();
});
remove()
範囲の AutoFilter を削除します。
remove(): void;
返品
void
注釈
例
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/worksheet-auto-filter.yaml
// This function removes all AutoFilters from the active worksheet.
await Excel.run(async (context) => {
// Retrieve the active worksheet.
const sheet = context.workbook.worksheets.getActiveWorksheet();
// Remove all filters.
sheet.autoFilter.remove();
await context.sync();
});
toJSON()
API オブジェクトが JSON.stringify() に渡されるときに、より有用な出力を提供するために、JavaScript toJSON() メソッドをオーバーライドします。 (次に、JSON.stringify渡されたオブジェクトの toJSON メソッドを呼び出します)。元の Excel.AutoFilter オブジェクトが API オブジェクトであるのに対し、 toJSON メソッドは、元のオブジェクトから読み込まれた子プロパティの浅いコピーを含むプレーンな JavaScript オブジェクト ( Excel.Interfaces.AutoFilterData と型指定) を返します。
toJSON(): Excel.Interfaces.AutoFilterData;