Word.TableRow class

Word 文書の行を表します。

Extends

注釈

API セット: WordApi 1.3

使用元

// 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 cell 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 firstCell: Word.TableCell = firstTableRow.cells.getFirst();
  firstCell.load(["horizontalAlignment", "verticalAlignment"]);
  await context.sync();

  console.log(
    `Details about the alignment of the first table's first cell:`,
    `- Horizontal alignment of the cell's content: ${firstCell.horizontalAlignment}`,
    `- Vertical alignment of the cell's content: ${firstCell.verticalAlignment}`,
  );
});

プロパティ

cellCount

行のセルの数を取得します。

cells

セルを取得します。

context

オブジェクトに関連付けられている要求コンテキスト。 これにより、アドインのプロセスが Office ホスト アプリケーションのプロセスに接続されます。

endnotes

テーブル行の文末脚注のコレクションを取得します。

fields

テーブル行の Field オブジェクトのコレクションを取得します。

font

フォントを取得します。 これを使用して、フォント名、サイズ、色、およびその他のプロパティを取得および設定します。

footnotes

テーブル行の脚注のコレクションを取得します。

horizontalAlignment

行のすべてのセルの水平方向の配置を指定します。 値には、 leftcenteredright、または justified を指定できます。

isHeader

行がヘッダー行であるかどうかを確認します。 ヘッダー行数を設定するには、Table オブジェクトで headerRowCount を使用します。

parentTable

親テーブルを取得します。

preferredHeight

行の優先高さをポイント単位で指定します。

range

テーブルの行を表す Range オブジェクトを返します。

rowIndex

親テーブル内の行のインデックスを取得します。

shading

テーブル行の網掛けを表す ShadingUniversal オブジェクトを返します。

shadingColor

網かけの色を指定します。 色は、"#RRGGBB" 形式で指定するか、色の名前を使用して指定します。

values

行のテキスト値を 2D JavaScript 配列として指定します。

verticalAlignment

行のセルの垂直方向の配置を指定します。 値には、 topcenter、または bottom を指定できます。

メソッド

clear()

行の内容をクリアします。

convertToText(options)

表の行をテキストに変換します。

delete()

行全体を削除します。

getBorder(borderLocation)

行のセルの罫線スタイルを取得します。

getBorder(borderLocation)

行のセルの罫線スタイルを取得します。

getCellPadding(cellPaddingLocation)

セル内のスペースをポイント単位で取得します。

getCellPadding(cellPaddingLocation)

セル内のスペースをポイント単位で取得します。

getNext()

次の行を取得します。 この行が最後の行である場合は、 ItemNotFound エラーをスローします。

getNextOrNullObject()

次の行を取得します。 この行が最後の行である場合、このメソッドは、 isNullObject プロパティが true に設定されたオブジェクトを返します。 詳細については、「 *OrNullObject のメソッドとプロパティ」を参照してください。

insertContentControl()

行にコンテンツ コントロールを挿入します。

insertRows(insertLocation, rowCount, values)

この行をテンプレートとして使用して、行を挿入します。 値を指定すると、新しい行に値を挿入します。

load(options)

オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。

load(propertyNames)

オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。

load(propertyNamesAndPaths)

オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。

merge()

行を 1 つのセルに結合します。

search(searchText, searchOptions)

行の範囲に対して、指定された検索オプションを使用して検索を実行します。 検索結果は、 Range オブジェクトのコレクションです。

select(selectionMode)

行を選択し、その行に Word の UI を移動します。

select(selectionMode)

行を選択し、その行に Word の UI を移動します。

set(properties, options)

オブジェクトの複数のプロパティを同時に設定します。 適切なプロパティを持つプレーン オブジェクト、または同じ型の別の API オブジェクトを渡すことができます。

set(properties)

既存の読み込まれたオブジェクトに基づいて、オブジェクトに複数のプロパティを同時に設定します。

setCellPadding(cellPaddingLocation, cellPadding)

セル内のスペースをポイント単位で設定します。

setCellPadding(cellPaddingLocation, cellPadding)

セル内のスペースをポイント単位で設定します。

setHeight(rowHeight, heightRule)

行の高さを設定します。

setHeight(rowHeight, heightRule)

行の高さを設定します。

setLeftIndent(leftIndent, rulerStyle)

テーブル行の左インデントを設定します。

setLeftIndent(leftIndent, rulerStyle)

テーブル行の左インデントを設定します。

toJSON()

API オブジェクトが JSON.stringify() に渡されるときに、より有用な出力を提供するために、JavaScript toJSON() メソッドをオーバーライドします。 (次に、JSON.stringify渡されたオブジェクトの toJSON メソッドを呼び出します)。元の Word.TableRow オブジェクトが API オブジェクトであるのに対し、 toJSON メソッドは、元のオブジェクトから読み込まれた子プロパティの浅いコピーを含むプレーンな JavaScript オブジェクト ( Word.Interfaces.TableRowData と型指定) を返します。

track()

ドキュメントの環境変更に基づいて自動的に調整する目的でオブジェクトを追跡します。 この呼び出しは、 context.trackedObjects.add(thisObject) の短縮形です。 このオブジェクトを .sync 呼び出しと ".run" バッチの連続実行の外部で使用していて、プロパティを設定したり、オブジェクトでメソッドを呼び出したりするときに "InvalidObjectPath" エラーが発生する場合は、オブジェクトが最初に作成されたときに、追跡対象のオブジェクト コレクションにオブジェクトを追加する必要があります。 このオブジェクトがコレクションの一部である場合は、親コレクションも追跡する必要があります。

untrack()

前に追跡されていた場合、このオブジェクトに関連付けられているメモリを解放します。 この呼び出しは、 context.trackedObjects.remove(thisObject) の省略形です。 追跡対象オブジェクトが多いとホスト アプリケーションの動作が遅くなります。追加したオブジェクトが不要になったら、必ずそれを解放してください。 メモリ リリースを有効にする前に、 context.sync() を呼び出す必要があります。

プロパティの詳細

cellCount

行のセルの数を取得します。

readonly cellCount: number;

プロパティ値

number

注釈

API セット: WordApi 1.3

cells

セルを取得します。

readonly cells: Word.TableCellCollection;

プロパティ値

注釈

API セット: WordApi 1.3

// 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 cell 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 firstCell: Word.TableCell = firstTableRow.cells.getFirst();
  firstCell.load(["horizontalAlignment", "verticalAlignment"]);
  await context.sync();

  console.log(
    `Details about the alignment of the first table's first cell:`,
    `- Horizontal alignment of the cell's content: ${firstCell.horizontalAlignment}`,
    `- Vertical alignment of the cell's content: ${firstCell.verticalAlignment}`,
  );
});

context

オブジェクトに関連付けられている要求コンテキスト。 これにより、アドインのプロセスが Office ホスト アプリケーションのプロセスに接続されます。

context: RequestContext;

プロパティ値

endnotes

テーブル行の文末脚注のコレクションを取得します。

readonly endnotes: Word.NoteItemCollection;

プロパティ値

注釈

API セット: WordAPI 1.5

fields

テーブル行の Field オブジェクトのコレクションを取得します。

readonly fields: Word.FieldCollection;

プロパティ値

注釈

API セット: WordApi 1.4

font

フォントを取得します。 これを使用して、フォント名、サイズ、色、およびその他のプロパティを取得および設定します。

readonly font: Word.Font;

プロパティ値

注釈

API セット: WordApi 1.3

footnotes

テーブル行の脚注のコレクションを取得します。

readonly footnotes: Word.NoteItemCollection;

プロパティ値

注釈

API セット: WordAPI 1.5

horizontalAlignment

行のすべてのセルの水平方向の配置を指定します。 値には、 leftcenteredright、または justified を指定できます。

horizontalAlignment: Word.Alignment | "Mixed" | "Unknown" | "Left" | "Centered" | "Right" | "Justified";

プロパティ値

Word.Alignment | "Mixed" | "Unknown" | "Left" | "Centered" | "Right" | "Justified"

注釈

API セット: WordApi 1.3

isHeader

行がヘッダー行であるかどうかを確認します。 ヘッダー行数を設定するには、Table オブジェクトで headerRowCount を使用します。

readonly isHeader: boolean;

プロパティ値

boolean

注釈

API セット: WordApi 1.3

parentTable

親テーブルを取得します。

readonly parentTable: Word.Table;

プロパティ値

注釈

API セット: WordApi 1.3

preferredHeight

行の優先高さをポイント単位で指定します。

preferredHeight: number;

プロパティ値

number

注釈

API セット: WordApi 1.3

range

テーブルの行を表す Range オブジェクトを返します。

readonly range: Word.Range;

プロパティ値

注釈

API セット: WordApiDesktop 1.4

rowIndex

親テーブル内の行のインデックスを取得します。

readonly rowIndex: number;

プロパティ値

number

注釈

API セット: WordApi 1.3

shading

テーブル行の網掛けを表す ShadingUniversal オブジェクトを返します。

readonly shading: Word.ShadingUniversal;

プロパティ値

注釈

API セット: WordApiDesktop 1.4

shadingColor

網かけの色を指定します。 色は、"#RRGGBB" 形式で指定するか、色の名前を使用して指定します。

shadingColor: string;

プロパティ値

string

注釈

API セット: WordApi 1.3

values

行のテキスト値を 2D JavaScript 配列として指定します。

values: string[][];

プロパティ値

string[][]

注釈

API セット: WordApi 1.3

verticalAlignment

行のセルの垂直方向の配置を指定します。 値には、 topcenter、または bottom を指定できます。

verticalAlignment: Word.VerticalAlignment | "Mixed" | "Top" | "Center" | "Bottom";

プロパティ値

Word.VerticalAlignment | "Mixed" | "Top" | "Center" | "Bottom"

注釈

API セット: WordApi 1.3

メソッドの詳細

clear()

行の内容をクリアします。

clear(): void;

返品

void

注釈

API セット: WordApi 1.3

convertToText(options)

表の行をテキストに変換します。

convertToText(options?: Word.TableConvertToTextOptions): Word.Range;

パラメーター

options
Word.TableConvertToTextOptions

省略可能。 表の行をテキストに変換するためのオプションを指定するオブジェクト。

返品

注釈

API セット: WordApiDesktop 1.4

delete()

行全体を削除します。

delete(): void;

返品

void

注釈

API セット: WordApi 1.3

getBorder(borderLocation)

行のセルの罫線スタイルを取得します。

getBorder(borderLocation: Word.BorderLocation): Word.TableBorder;

パラメーター

borderLocation
Word.BorderLocation

境界の場所。

返品

注釈

API セット: WordApi 1.3

// 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`,
  );
});

getBorder(borderLocation)

行のセルの罫線スタイルを取得します。

getBorder(borderLocation: "Top" | "Left" | "Bottom" | "Right" | "InsideHorizontal" | "InsideVertical" | "Inside" | "Outside" | "All"): Word.TableBorder;

パラメーター

borderLocation

"Top" | "Left" | "Bottom" | "Right" | "InsideHorizontal" | "InsideVertical" | "Inside" | "Outside" | "All"

境界の場所。

返品

注釈

API セット: WordApi 1.3

getCellPadding(cellPaddingLocation)

セル内のスペースをポイント単位で取得します。

getCellPadding(cellPaddingLocation: Word.CellPaddingLocation): OfficeExtension.ClientResult<number>;

パラメーター

cellPaddingLocation
Word.CellPaddingLocation

セルに埋め込む場所は、 topleftbottom、または right である必要があります。

返品

注釈

API セット: WordApi 1.3

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/40-tables/manage-formatting.yaml

// Gets cell padding 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 cellPaddingLocation = Word.CellPaddingLocation.bottom;
  const cellPadding = firstTableRow.getCellPadding(cellPaddingLocation);
  await context.sync();

  console.log(
    `Cell padding details about the ${cellPaddingLocation} border of the first table's first row: ${cellPadding.value} points`,
  );
});

getCellPadding(cellPaddingLocation)

セル内のスペースをポイント単位で取得します。

getCellPadding(cellPaddingLocation: "Top" | "Left" | "Bottom" | "Right"): OfficeExtension.ClientResult<number>;

パラメーター

cellPaddingLocation

"Top" | "Left" | "Bottom" | "Right"

セルに埋め込む場所は、 topleftbottom、または right である必要があります。

返品

注釈

API セット: WordApi 1.3

getNext()

次の行を取得します。 この行が最後の行である場合は、 ItemNotFound エラーをスローします。

getNext(): Word.TableRow;

返品

注釈

API セット: WordApi 1.3

getNextOrNullObject()

次の行を取得します。 この行が最後の行である場合、このメソッドは、 isNullObject プロパティが true に設定されたオブジェクトを返します。 詳細については、「 *OrNullObject のメソッドとプロパティ」を参照してください。

getNextOrNullObject(): Word.TableRow;

返品

注釈

API セット: WordApi 1.3

insertContentControl()

行にコンテンツ コントロールを挿入します。

insertContentControl(): Word.ContentControl;

返品

注釈

API セット: WordApiDesktop 1.1

insertRows(insertLocation, rowCount, values)

この行をテンプレートとして使用して、行を挿入します。 値を指定すると、新しい行に値を挿入します。

insertRows(insertLocation: Word.InsertLocation.before | Word.InsertLocation.after | "Before" | "After", rowCount: number, values?: string[][]): Word.TableRowCollection;

パラメーター

insertLocation

before | after | "Before" | "After"

現在の行を基準にして、新しい行を挿入する場所。 before または after である必要があります。

rowCount

number

追加する行数。

values

string[][]

省略可能。 新しい行に挿入する文字列で、2D 配列として指定されます。 各行のセル数は、既存の行のセル数を超えてはなりません。

返品

注釈

API セット: WordApi 1.3

load(options)

オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。

load(options?: Word.Interfaces.TableRowLoadOptions): Word.TableRow;

パラメーター

options
Word.Interfaces.TableRowLoadOptions

読み込むオブジェクトのプロパティのオプションを指定します。

返品

load(propertyNames)

オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。

load(propertyNames?: string | string[]): Word.TableRow;

パラメーター

propertyNames

string | string[]

読み込むプロパティを指定するコンマ区切りの文字列または文字列の配列。

返品

load(propertyNamesAndPaths)

オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。

load(propertyNamesAndPaths?: {
            select?: string;
            expand?: string;
        }): Word.TableRow;

パラメーター

propertyNamesAndPaths

{ select?: string; expand?: string; }

propertyNamesAndPaths.select は読み込むプロパティを指定するコンマ区切りの文字列であり、 propertyNamesAndPaths.expand は読み込むナビゲーションのプロパティを指定するコンマ区切りの文字列です。

返品

merge()

行を 1 つのセルに結合します。

merge(): Word.TableCell;

返品

注釈

API セット: WordApi 1.4

search(searchText, searchOptions)

行の範囲に対して、指定された検索オプションを使用して検索を実行します。 検索結果は、 Range オブジェクトのコレクションです。

search(searchText: string, searchOptions?: Word.SearchOptions | {
            ignorePunct?: boolean;
            ignoreSpace?: boolean;
            matchCase?: boolean;
            matchPrefix?: boolean;
            matchSuffix?: boolean;
            matchWholeWord?: boolean;
            matchWildcards?: boolean;
        }): Word.RangeCollection;

パラメーター

searchText

string

検索テキスト。

searchOptions

Word.SearchOptions | { ignorePunct?: boolean; ignoreSpace?: boolean; matchCase?: boolean; matchPrefix?: boolean; matchSuffix?: boolean; matchWholeWord?: boolean; matchWildcards?: boolean; }

省略可能。 検索のオプション。

返品

注釈

API セット: WordApi 1.3

select(selectionMode)

行を選択し、その行に Word の UI を移動します。

select(selectionMode?: Word.SelectionMode): void;

パラメーター

selectionMode
Word.SelectionMode

省略可能。 選択モードは、 selectstart、または end である必要があります。 select が既定です。

返品

void

注釈

API セット: WordApi 1.3

select(selectionMode)

行を選択し、その行に Word の UI を移動します。

select(selectionMode?: "Select" | "Start" | "End"): void;

パラメーター

selectionMode

"Select" | "Start" | "End"

省略可能。 選択モードは、 selectstart、または end である必要があります。 select が既定です。

返品

void

注釈

API セット: WordApi 1.3

set(properties, options)

オブジェクトの複数のプロパティを同時に設定します。 適切なプロパティを持つプレーン オブジェクト、または同じ型の別の API オブジェクトを渡すことができます。

set(properties: Interfaces.TableRowUpdateData, options?: OfficeExtension.UpdateOptions): void;

パラメーター

properties
Word.Interfaces.TableRowUpdateData

メソッドが呼び出されたオブジェクトのプロパティと同型構造のプロパティを持つ JavaScript オブジェクト。

options
OfficeExtension.UpdateOptions

プロパティ オブジェクトが読み取り専用プロパティを設定しようとした場合にエラーを抑制するオプションを提供します。

返品

void

set(properties)

既存の読み込まれたオブジェクトに基づいて、オブジェクトに複数のプロパティを同時に設定します。

set(properties: Word.TableRow): void;

パラメーター

properties
Word.TableRow

返品

void

setCellPadding(cellPaddingLocation, cellPadding)

セル内のスペースをポイント単位で設定します。

setCellPadding(cellPaddingLocation: Word.CellPaddingLocation, cellPadding: number): void;

パラメーター

cellPaddingLocation
Word.CellPaddingLocation

セルに埋め込む場所は、 topleftbottom、または right である必要があります。

cellPadding

number

セルのパディング。

返品

void

注釈

API セット: WordApi 1.3

setCellPadding(cellPaddingLocation, cellPadding)

セル内のスペースをポイント単位で設定します。

setCellPadding(cellPaddingLocation: "Top" | "Left" | "Bottom" | "Right", cellPadding: number): void;

パラメーター

cellPaddingLocation

"Top" | "Left" | "Bottom" | "Right"

セルに埋め込む場所は、 topleftbottom、または right である必要があります。

cellPadding

number

セルのパディング。

返品

void

注釈

API セット: WordApi 1.3

setHeight(rowHeight, heightRule)

行の高さを設定します。

setHeight(rowHeight: number, heightRule: Word.RowHeightRule): void;

パラメーター

rowHeight

number

行の高さをポイント単位で指定します。

heightRule
Word.RowHeightRule

テーブル行の高さを決定するためのルール。

返品

void

注釈

API セット: WordApiDesktop 1.4

setHeight(rowHeight, heightRule)

行の高さを設定します。

setHeight(rowHeight: number, heightRule: "Auto" | "AtLeast" | "Exactly"): void;

パラメーター

rowHeight

number

行の高さをポイント単位で指定します。

heightRule

"Auto" | "AtLeast" | "Exactly"

テーブル行の高さを決定するためのルール。

返品

void

注釈

API セット: WordApiDesktop 1.4

setLeftIndent(leftIndent, rulerStyle)

テーブル行の左インデントを設定します。

setLeftIndent(leftIndent: number, rulerStyle: Word.RulerStyle): void;

パラメーター

leftIndent

number

テーブル行の現在の左端と目的の左端の間の距離 (ポイント単位)。

rulerStyle
Word.RulerStyle

適用するルーラー スタイル。

返品

void

注釈

API セット: WordApiDesktop 1.4

setLeftIndent(leftIndent, rulerStyle)

テーブル行の左インデントを設定します。

setLeftIndent(leftIndent: number, rulerStyle: "None" | "Proportional" | "FirstColumn" | "SameWidth"): void;

パラメーター

leftIndent

number

テーブル行の現在の左端と目的の左端の間の距離 (ポイント単位)。

rulerStyle

"None" | "Proportional" | "FirstColumn" | "SameWidth"

適用するルーラー スタイル。

返品

void

注釈

API セット: WordApiDesktop 1.4

toJSON()

API オブジェクトが JSON.stringify() に渡されるときに、より有用な出力を提供するために、JavaScript toJSON() メソッドをオーバーライドします。 (次に、JSON.stringify渡されたオブジェクトの toJSON メソッドを呼び出します)。元の Word.TableRow オブジェクトが API オブジェクトであるのに対し、 toJSON メソッドは、元のオブジェクトから読み込まれた子プロパティの浅いコピーを含むプレーンな JavaScript オブジェクト ( Word.Interfaces.TableRowData と型指定) を返します。

toJSON(): Word.Interfaces.TableRowData;

返品

track()

ドキュメントの環境変更に基づいて自動的に調整する目的でオブジェクトを追跡します。 この呼び出しは、 context.trackedObjects.add(thisObject) の短縮形です。 このオブジェクトを .sync 呼び出しと ".run" バッチの連続実行の外部で使用していて、プロパティを設定したり、オブジェクトでメソッドを呼び出したりするときに "InvalidObjectPath" エラーが発生する場合は、オブジェクトが最初に作成されたときに、追跡対象のオブジェクト コレクションにオブジェクトを追加する必要があります。 このオブジェクトがコレクションの一部である場合は、親コレクションも追跡する必要があります。

track(): Word.TableRow;

返品

untrack()

前に追跡されていた場合、このオブジェクトに関連付けられているメモリを解放します。 この呼び出しは、 context.trackedObjects.remove(thisObject) の省略形です。 追跡対象オブジェクトが多いとホスト アプリケーションの動作が遅くなります。追加したオブジェクトが不要になったら、必ずそれを解放してください。 メモリ リリースを有効にする前に、 context.sync() を呼び出す必要があります。

untrack(): Word.TableRow;

返品