Excel.CustomPropertyCollection class
カスタム プロパティのコレクションが含まれます。
- Extends
プロパティ
| context | オブジェクトに関連付けられている要求コンテキスト。 これにより、アドインのプロセスが Office ホスト アプリケーションのプロセスに接続されます。 |
| items | このコレクション内に読み込まれた子アイテムを取得します。 |
メソッド
| add(key, value) | 新しいカスタム プロパティを作成、または既存のカスタム プロパティを設定します。 |
| delete |
このコレクション内のすべてのカスタム プロパティを削除します。 |
| get |
カスタム プロパティの数を取得します。 |
| get |
キーを使用してカスタム プロパティ オブジェクトを取得します。大文字と小文字は区別されません。 カスタム プロパティが存在しない場合はエラーをスローします。 |
| get |
キーを使用してカスタム プロパティ オブジェクトを取得します。大文字と小文字は区別されません。 カスタム プロパティが存在しない場合、このメソッドは |
| load(options) | オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、 |
| load(property |
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、 |
| load(property |
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、 |
| toJSON() | API オブジェクトが |
プロパティの詳細
context
オブジェクトに関連付けられている要求コンテキスト。 これにより、アドインのプロセスが Office ホスト アプリケーションのプロセスに接続されます。
context: RequestContext;
プロパティ値
items
メソッドの詳細
add(key, value)
新しいカスタム プロパティを作成、または既存のカスタム プロパティを設定します。
add(key: string, value: any): Excel.CustomProperty;
パラメーター
- key
-
string
必須です。 カスタム プロパティのキーです。大文字と小文字は区別されません。 キーは Excel on the web 以外では 255 文字に制限されます (他のプラットフォームでは、キーが大きいほど自動的に 255 文字にトリミングされます)。
- value
-
any
必須です。 カスタム プロパティの値。 この値は、Excel on the web 以外では 255 文字に制限されます (他のプラットフォームでは、値が大きくなると自動的に 255 文字にトリミングされます)。
返品
注釈
例
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/26-document/custom-properties.yaml
await Excel.run(async (context) => {
// Get the key/value pair from the task pane.
const userKey = document.getElementById("key").textContent;
const userValue = document.getElementById("value").textContent;
// Add the custom property.
const customDocProperties = context.workbook.properties.custom;
customDocProperties.add(userKey, userValue);
await context.sync();
console.log(`Successfully set custom document property ${userKey}: ${userValue}.`);
});
deleteAll()
getCount()
カスタム プロパティの数を取得します。
getCount(): OfficeExtension.ClientResult<number>;
返品
OfficeExtension.ClientResult<number>
注釈
getItem(key)
キーを使用してカスタム プロパティ オブジェクトを取得します。大文字と小文字は区別されません。 カスタム プロパティが存在しない場合はエラーをスローします。
getItem(key: string): Excel.CustomProperty;
パラメーター
- key
-
string
カスタム プロパティ オブジェクトを識別するキー。
返品
注釈
getItemOrNullObject(key)
キーを使用してカスタム プロパティ オブジェクトを取得します。大文字と小文字は区別されません。 カスタム プロパティが存在しない場合、このメソッドは isNullObject プロパティが true に設定されたオブジェクトを返します。 詳細については、「 *OrNullObject のメソッドとプロパティ」を参照してください。
getItemOrNullObject(key: string): Excel.CustomProperty;
パラメーター
- key
-
string
必須です。 カスタム プロパティ オブジェクトを識別するキー。
返品
注釈
load(options)
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。
load(options?: Excel.Interfaces.CustomPropertyCollectionLoadOptions & Excel.Interfaces.CollectionLoadOptions): Excel.CustomPropertyCollection;
パラメーター
- options
-
Excel.Interfaces.CustomPropertyCollectionLoadOptions & Excel.Interfaces.CollectionLoadOptions
読み込むオブジェクトのプロパティのオプションを指定します。
返品
load(propertyNames)
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。
load(propertyNames?: string | string[]): Excel.CustomPropertyCollection;
パラメーター
- propertyNames
-
string | string[]
読み込むプロパティを指定するコンマ区切りの文字列または文字列の配列。
返品
load(propertyNamesAndPaths)
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。
load(propertyNamesAndPaths?: OfficeExtension.LoadOption): Excel.CustomPropertyCollection;
パラメーター
- propertyNamesAndPaths
- OfficeExtension.LoadOption
propertyNamesAndPaths.select は読み込むプロパティを指定するコンマ区切りの文字列であり、 propertyNamesAndPaths.expand は読み込むナビゲーションのプロパティを指定するコンマ区切りの文字列です。
返品
toJSON()
API オブジェクトが JSON.stringify() に渡されるときに、より有用な出力を提供するために、JavaScript toJSON() メソッドをオーバーライドします。 (次に、JSON.stringify渡されたオブジェクトの toJSON メソッドを呼び出します)。元の Excel.CustomPropertyCollection オブジェクトが API オブジェクトであるのに対し、 toJSON メソッドは、コレクションの項目から読み込まれたプロパティの浅いコピーを含む "items" 配列を含むプレーンな JavaScript オブジェクト ( Excel.Interfaces.CustomPropertyCollectionData として型指定された) を返します。
toJSON(): Excel.Interfaces.CustomPropertyCollectionData;