Word.TableRowCollection class
ドキュメントのWordのコレクションを格納します。TableRow オブジェクト。
- Extends
注釈
例
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/40-tables/manage-formatting.yaml
// Gets content alignment details about the first row of the first table in the document.
await Word.run(async (context) => {
const firstTable: Word.Table = context.document.body.tables.getFirst();
const firstTableRow: Word.TableRow = firstTable.rows.getFirst();
firstTableRow.load(["horizontalAlignment", "verticalAlignment"]);
await context.sync();
console.log(`Details about the alignment of the first table's first row:`, `- Horizontal alignment of every cell in the row: ${firstTableRow.horizontalAlignment}`, `- Vertical alignment of every cell in the row: ${firstTableRow.verticalAlignment}`);
});
プロパティ
| context | オブジェクトに関連付けられている要求コンテキスト。 これにより、アドインのプロセスが Office ホスト アプリケーションのプロセスに接続されます。 |
| items | このコレクション内に読み込まれた子アイテムを取得します。 |
メソッド
| convert |
テーブル内の行をテキストに変換します。 |
| delete() | テーブル行を削除します。 |
| distribute |
行の高さを調整して、行が等しくなるようにします。 |
| get |
このコレクション内の最初の行を取得します。 このコレクションが空の場合は、 |
| get |
このコレクション内の最初の行を取得します。 このコレクションが空の場合、このメソッドは |
| load(options) | オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、 |
| load(property |
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、 |
| load(property |
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、 |
| select() | テーブル行を選択します。 |
| set |
テーブル内のセルの高さを設定します。 |
| set |
テーブル内のセルの高さを設定します。 |
| set |
テーブル行の左インデントを設定します。 |
| set |
テーブル行の左インデントを設定します。 |
| toJSON() | API オブジェクトが |
| track() | ドキュメントの環境変更に基づいて自動的に調整する目的でオブジェクトを追跡します。 この呼び出しは、 context.trackedObjects.add(thisObject)の短縮形です。 このオブジェクトを |
| untrack() | 前に追跡されていた場合、このオブジェクトに関連付けられているメモリを解放します。 この呼び出しは 、context.trackedObjects.remove(thisObject)の短縮形です。 追跡対象オブジェクトが多いとホスト アプリケーションの動作が遅くなります。追加したオブジェクトが不要になったら、必ずそれを解放してください。 メモリ解放が有効になる前に、 |
プロパティの詳細
context
オブジェクトに関連付けられている要求コンテキスト。 これにより、アドインのプロセスが Office ホスト アプリケーションのプロセスに接続されます。
context: RequestContext;
プロパティ値
items
メソッドの詳細
convertToText(options)
テーブル内の行をテキストに変換します。
convertToText(options?: Word.TableConvertToTextOptions): Word.Range;
パラメーター
- options
- Word.TableConvertToTextOptions
省略可能。 テーブル行をテキストに変換するためのオプションを指定する オブジェクト。
戻り値
変換されたテキストを表す Range オブジェクト。
注釈
delete()
distributeHeight()
getFirst()
このコレクション内の最初の行を取得します。 このコレクションが空の場合は、 ItemNotFound エラーをスローします。
getFirst(): Word.TableRow;
戻り値
注釈
例
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/40-tables/manage-formatting.yaml
// Gets border details about the first row of the first table in the document.
await Word.run(async (context) => {
const firstTable: Word.Table = context.document.body.tables.getFirst();
const firstTableRow: Word.TableRow = firstTable.rows.getFirst();
const borderLocation = Word.BorderLocation.bottom;
const border: Word.TableBorder = firstTableRow.getBorder(borderLocation);
border.load(["type", "color", "width"]);
await context.sync();
console.log(`Details about the ${borderLocation} border of the first table's first row:`, `- Color: ${border.color}`, `- Type: ${border.type}`, `- Width: ${border.width} points`);
});
getFirstOrNullObject()
このコレクション内の最初の行を取得します。 このコレクションが空の場合、このメソッドは isNullObject プロパティを true に設定したオブジェクトを返します。 詳細については、「 *OrNullObject メソッドとプロパティ」を参照してください。
getFirstOrNullObject(): Word.TableRow;
戻り値
注釈
load(options)
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。
load(options?: Word.Interfaces.TableRowCollectionLoadOptions & Word.Interfaces.CollectionLoadOptions): Word.TableRowCollection;
パラメーター
読み込むオブジェクトのプロパティのオプションを提供します。
戻り値
load(propertyNames)
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。
load(propertyNames?: string | string[]): Word.TableRowCollection;
パラメーター
- propertyNames
-
string | string[]
読み込むプロパティを指定するコンマ区切り文字列または文字列の配列。
戻り値
load(propertyNamesAndPaths)
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。
load(propertyNamesAndPaths?: OfficeExtension.LoadOption): Word.TableRowCollection;
パラメーター
- propertyNamesAndPaths
- OfficeExtension.LoadOption
propertyNamesAndPaths.select は読み込むプロパティを指定するコンマ区切りの文字列で、 propertyNamesAndPaths.expand は読み込むナビゲーション プロパティを指定するコンマ区切りの文字列です。
戻り値
select()
setHeight(rowHeight, heightRule)
テーブル内のセルの高さを設定します。
setHeight(rowHeight: number, heightRule: Word.RowHeightRule): void;
パラメーター
- rowHeight
-
number
行の高さをポイント単位で指定します。
- heightRule
- Word.RowHeightRule
操作対象の行の高さを決めるときの規則を指定します。
戻り値
void
注釈
setHeight(rowHeight, heightRule)
テーブル内のセルの高さを設定します。
setHeight(rowHeight: number, heightRule: "Auto" | "AtLeast" | "Exactly"): void;
パラメーター
- rowHeight
-
number
行の高さをポイント単位で指定します。
- heightRule
-
"Auto" | "AtLeast" | "Exactly"
操作対象の行の高さを決めるときの規則を指定します。
戻り値
void
注釈
setLeftIndent(leftIndent, rulerStyle)
テーブル行の左インデントを設定します。
setLeftIndent(leftIndent: number, rulerStyle: Word.RulerStyle): void;
パラメーター
- leftIndent
-
number
指定した行の現在の左端と目的の左端との距離 (ポイント単位)。
- rulerStyle
- Word.RulerStyle
適用するルーラー スタイル。
戻り値
void
注釈
setLeftIndent(leftIndent, rulerStyle)
テーブル行の左インデントを設定します。
setLeftIndent(leftIndent: number, rulerStyle: "None" | "Proportional" | "FirstColumn" | "SameWidth"): void;
パラメーター
- leftIndent
-
number
指定した行の現在の左端と目的の左端との距離 (ポイント単位)。
- rulerStyle
-
"None" | "Proportional" | "FirstColumn" | "SameWidth"
適用するルーラー スタイル。
戻り値
void
注釈
toJSON()
API オブジェクトがJSON.stringify()に渡されたときにより便利な出力を提供するために、JavaScript toJSON() メソッドをオーバーライドします。 (JSON.stringify、それに渡されるオブジェクトの toJSON メソッドを呼び出します)。元の Word.TableRowCollection オブジェクトは API オブジェクトですが、 toJSON メソッドは、コレクションの項目から読み込まれたプロパティの浅いコピーを含む "items" 配列を含むプレーンな JavaScript オブジェクト ( Word.Interfaces.TableRowCollectionDataとして型指定) を返します。
toJSON(): Word.Interfaces.TableRowCollectionData;
戻り値
track()
ドキュメントの環境変更に基づいて自動的に調整する目的でオブジェクトを追跡します。 この呼び出しは、 context.trackedObjects.add(thisObject)の短縮形です。 このオブジェクトを .sync 呼び出しで使用し、".run" バッチのシーケンシャル実行の外部でプロパティを設定するとき、またはオブジェクトに対してメソッドを呼び出すときに "InvalidObjectPath" エラーが発生する場合は、オブジェクトが最初に作成されたときに、追跡対象のオブジェクト コレクションにオブジェクトを追加する必要があります。 このオブジェクトがコレクションの一部である場合は、親コレクションも追跡する必要があります。
track(): Word.TableRowCollection;
戻り値
untrack()
前に追跡されていた場合、このオブジェクトに関連付けられているメモリを解放します。 この呼び出しは 、context.trackedObjects.remove(thisObject)の短縮形です。 追跡対象オブジェクトが多いとホスト アプリケーションの動作が遅くなります。追加したオブジェクトが不要になったら、必ずそれを解放してください。 メモリ解放が有効になる前に、 context.sync() を呼び出す必要があります。
untrack(): Word.TableRowCollection;