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() | 範囲に現在指定されている AutoFilter オブジェクトを適用します。 |
remove() | 範囲の AutoFilter を削除します。 |
toJSON() | API オブジェクトが に渡されたときにより便利な出力を提供するために、JavaScript |
プロパティの詳細
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
クリアする必要がある列フィルターを表す、0 から始まる列インデックス。 インデックス値がサポートされていない場合 (たとえば、値が負の数の場合、または値が範囲内の使用可能な 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
適用される範囲を表す オブジェクトを返します。 AutoFilter に関連付けられているオブジェクトがない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()
範囲に現在指定されている AutoFilter オブジェクトを適用します。
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 オブジェクトが に渡されたときにより便利な出力を提供するために、JavaScript toJSON()
メソッドを JSON.stringify()
オーバーライドします。 (JSON.stringify
さらに、渡される オブジェクトの メソッドを呼び出 toJSON
します)。元の Excel.AutoFilter オブジェクトは API オブジェクトですが、メソッドは、元の toJSON
オブジェクトから読み込まれた子プロパティの浅いコピーを含むプレーンな JavaScript オブジェクト (として Excel.Interfaces.AutoFilterData
型指定) を返します。
toJSON(): Excel.Interfaces.AutoFilterData;
戻り値
Office Add-ins
フィードバック
https://aka.ms/ContentUserFeedback」を参照してください。
以下は間もなく提供いたします。2024 年を通じて、コンテンツのフィードバック メカニズムとして GitHub の issue を段階的に廃止し、新しいフィードバック システムに置き換えます。 詳細については、「フィードバックの送信と表示