PowerPoint.TableCell class
テーブルを表します。
- Extends
注釈
[ API セット: PowerPointApi 1.8 ]
例
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml
// Updates a table's values.
await PowerPoint.run(async (context) => {
const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes;
// Add a table (which is a type of Shape).
const shape = shapes.addTable(4, 3);
let table = shape.getTable();
table.load();
await context.sync();
// Update values in the table.
for (let rowIndex = 0; rowIndex < table.rowCount; rowIndex++) {
for (let columnIndex = 0; columnIndex < table.columnCount; columnIndex++) {
const cell = table.getCellOrNullObject(rowIndex, columnIndex);
cell.text = generateRandomString();
}
}
await context.sync();
});
プロパティ
| column |
このセルがまたがるテーブル列の数を取得します。 1 以上になります。 |
| column |
テーブル内のセルの 0 から始まる列インデックスを取得します。 |
| context | オブジェクトに関連付けられている要求コンテキスト。 これにより、アドインのプロセスが Office ホスト アプリケーションのプロセスに接続されます。 |
| row |
このセルがまたがるテーブル行の数を取得します。 1 以上になります。 |
| row |
テーブル内のセルの 0 から始まる行インデックスを取得します。 |
| text | テーブル セルのテキストコンテンツを指定します。 |
メソッド
| load(options) | オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、 |
| load(property |
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、 |
| load(property |
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、 |
| toJSON() | API オブジェクトが |
プロパティの詳細
columnCount
このセルがまたがるテーブル列の数を取得します。 1 以上になります。
readonly columnCount: number;
プロパティ値
number
注釈
columnIndex
テーブル内のセルの 0 から始まる列インデックスを取得します。
readonly columnIndex: number;
プロパティ値
number
注釈
context
オブジェクトに関連付けられている要求コンテキスト。 これにより、アドインのプロセスが Office ホスト アプリケーションのプロセスに接続されます。
context: RequestContext;
プロパティ値
rowCount
このセルがまたがるテーブル行の数を取得します。 1 以上になります。
readonly rowCount: number;
プロパティ値
number
注釈
rowIndex
テーブル内のセルの 0 から始まる行インデックスを取得します。
readonly rowIndex: number;
プロパティ値
number
注釈
text
テーブル セルのテキストコンテンツを指定します。
text: string;
プロパティ値
string
注釈
[ API セット: PowerPointApi 1.8 ]
例
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml
// Updates a table's values.
await PowerPoint.run(async (context) => {
const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes;
// Add a table (which is a type of Shape).
const shape = shapes.addTable(4, 3);
let table = shape.getTable();
table.load();
await context.sync();
// Update values in the table.
for (let rowIndex = 0; rowIndex < table.rowCount; rowIndex++) {
for (let columnIndex = 0; columnIndex < table.columnCount; columnIndex++) {
const cell = table.getCellOrNullObject(rowIndex, columnIndex);
cell.text = generateRandomString();
}
}
await context.sync();
});
メソッドの詳細
load(options)
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。
load(options?: PowerPoint.Interfaces.TableCellLoadOptions): PowerPoint.TableCell;
パラメーター
読み込むオブジェクトのプロパティのオプションを提供します。
戻り値
load(propertyNames)
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。
load(propertyNames?: string | string[]): PowerPoint.TableCell;
パラメーター
- propertyNames
-
string | string[]
読み込むプロパティを指定するコンマ区切り文字列または文字列の配列。
戻り値
load(propertyNamesAndPaths)
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。
load(propertyNamesAndPaths?: {
select?: string;
expand?: string;
}): PowerPoint.TableCell;
パラメーター
- propertyNamesAndPaths
-
{ select?: string; expand?: string; }
propertyNamesAndPaths.select は読み込むプロパティを指定するコンマ区切りの文字列で、 propertyNamesAndPaths.expand は読み込むナビゲーション プロパティを指定するコンマ区切りの文字列です。
戻り値
toJSON()
API オブジェクトがJSON.stringify()に渡されたときにより便利な出力を提供するために、JavaScript toJSON() メソッドをオーバーライドします。 (JSON.stringify、それに渡されるオブジェクトの toJSON メソッドを呼び出します)。元の PowerPoint.TableCell オブジェクトは API オブジェクトですが、 toJSON メソッドは、元のオブジェクトから読み込まれた子プロパティの浅いコピーを含むプレーンな JavaScript オブジェクト ( PowerPoint.Interfaces.TableCellData として型指定) を返します。
toJSON(): PowerPoint.Interfaces.TableCellData;