Word.TableCell class

Word ドキュメント内のテーブル セルを表します。

Extends

注釈

[ API セット: WordApi 1.3 ]

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

// Gets the content of the first cell in the first table.
await Word.run(async (context) => {
  const firstCell = context.document.body.tables.getFirst().getCell(0, 0).body;
  firstCell.load("text");

  await context.sync();
  console.log("First cell's text is: " + firstCell.text);
});

プロパティ

body

セルの本文オブジェクトを取得します。

cellIndex

その行のセルのインデックスを取得します。

columnWidth

セルの列の幅をポイント単位で指定します。 これは、統一されたテーブルに適用可能です。

context

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

horizontalAlignment

セルの水平方向の配置を指定します。 値には、'Left'、'Centered'、'Right'、または 'Justified' を指定できます。

parentRow

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

parentTable

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

rowIndex

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

shadingColor

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

value

セルのテキストを指定します。

verticalAlignment

セルの垂直方向の配置を指定します。 値には、'Top'、'Center'、または 'Bottom' を指定できます。

width

セルの幅をポイント単位で取得します。

メソッド

deleteColumn()

このセルを含む列を削除します。 これは、統一されたテーブルに適用可能です。

deleteRow()

このセルを含む行を削除します。

getBorder(borderLocation)

指定した罫線の罫線スタイルを取得します。

getBorder(borderLocationString)

指定した罫線の罫線スタイルを取得します。

getCellPadding(cellPaddingLocation)

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

getCellPadding(cellPaddingLocationString)

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

getNext()

次のセルを取得します。 このセルが最後の ItemNotFound セルの場合は、エラーをスローします。

getNextOrNullObject()

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

insertColumns(insertLocation, columnCount, values)

セルの列をテンプレートとして使用して、列をセルの左または右に追加します。 これは、統一されたテーブルに適用可能です。 指定すると、文字列値は新しく挿入された行に設定されます。

insertRows(insertLocation, rowCount, values)

セルの行をテンプレートとして使用して、行をセルの上または下に挿入します。 指定すると、文字列値は新しく挿入された行に設定されます。

load(options)

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

load(propertyNames)

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

load(propertyNamesAndPaths)

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

set(properties, options)

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

set(properties)

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

setCellPadding(cellPaddingLocation, cellPadding)

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

setCellPadding(cellPaddingLocationString, cellPadding)

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

split(rowCount, columnCount)

セルを指定した数の行と列に分割します。

toJSON()

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

track()

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

untrack()

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

プロパティの詳細

body

セルの本文オブジェクトを取得します。

readonly body: Word.Body;

プロパティ値

注釈

[ API セット: WordApi 1.3 ]

cellIndex

その行のセルのインデックスを取得します。

readonly cellIndex: number;

プロパティ値

number

注釈

[ API セット: WordApi 1.3 ]

columnWidth

セルの列の幅をポイント単位で指定します。 これは、統一されたテーブルに適用可能です。

columnWidth: number;

プロパティ値

number

注釈

[ API セット: WordApi 1.3 ]

context

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

context: RequestContext;

プロパティ値

horizontalAlignment

セルの水平方向の配置を指定します。 値には、'Left'、'Centered'、'Right'、または 'Justified' を指定できます。

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

プロパティ値

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

注釈

[ 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 = context.document.body.tables.getFirst();
  const firstCell = firstTable.getCell(0, 0);
  firstCell.load(["horizontalAlignment", "verticalAlignment"]);
  await context.sync();

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

parentRow

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

readonly parentRow: Word.TableRow;

プロパティ値

注釈

[ API セット: WordApi 1.3 ]

parentTable

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

readonly parentTable: Word.Table;

プロパティ値

注釈

[ API セット: WordApi 1.3 ]

rowIndex

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

readonly rowIndex: number;

プロパティ値

number

注釈

[ API セット: WordApi 1.3 ]

shadingColor

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

shadingColor: string;

プロパティ値

string

注釈

[ API セット: WordApi 1.3 ]

value

セルのテキストを指定します。

value: string;

プロパティ値

string

注釈

[ API セット: WordApi 1.3 ]

verticalAlignment

セルの垂直方向の配置を指定します。 値には、'Top'、'Center'、または 'Bottom' を指定できます。

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

プロパティ値

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

注釈

[ 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 = context.document.body.tables.getFirst();
  const firstCell = firstTable.getCell(0, 0);
  firstCell.load(["horizontalAlignment", "verticalAlignment"]);
  await context.sync();

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

width

セルの幅をポイント単位で取得します。

readonly width: number;

プロパティ値

number

注釈

[ API セット: WordApi 1.3 ]

メソッドの詳細

deleteColumn()

このセルを含む列を削除します。 これは、統一されたテーブルに適用可能です。

deleteColumn(): void;

戻り値

void

注釈

[ API セット: WordApi 1.3 ]

deleteRow()

このセルを含む行を削除します。

deleteRow(): void;

戻り値

void

注釈

[ API セット: WordApi 1.3 ]

getBorder(borderLocation)

指定した罫線の罫線スタイルを取得します。

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

パラメーター

borderLocation
Word.BorderLocation

必須です。 罫線の場所。

戻り値

注釈

[ API セット: WordApi 1.3 ]

getBorder(borderLocationString)

指定した罫線の罫線スタイルを取得します。

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

パラメーター

borderLocationString

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

必須です。 罫線の場所。

戻り値

注釈

[ 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 of the first table in the document.
await Word.run(async (context) => {
  const firstTable = context.document.body.tables.getFirst();
  const firstCell = firstTable.getCell(0, 0);
  const borderLocation = "Left";
  const border = firstCell.getBorder(borderLocation);
  border.load(["type", "color", "width"]);
  await context.sync();

  console.log(`Details about the ${borderLocation} border of the first table's first cell:`);
  console.log(`- Color: ${border.color}`);
  console.log(`- Type: ${border.type}`);
  console.log(`- Width: ${border.width} points`);
});

getCellPadding(cellPaddingLocation)

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

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

パラメーター

cellPaddingLocation
Word.CellPaddingLocation

必須です。 セルのパディングの場所は、'Top'、'Left'、'Bottom'、または 'Right' である必要があります。

戻り値

注釈

[ API セット: WordApi 1.3 ]

getCellPadding(cellPaddingLocationString)

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

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

パラメーター

cellPaddingLocationString

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

必須です。 セルのパディングの場所は、'Top'、'Left'、'Bottom'、または '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 cell of the first table in the document.
await Word.run(async (context) => {
  const firstTable = context.document.body.tables.getFirst();
  const firstCell = firstTable.getCell(0, 0);
  const cellPaddingLocation = "Left";
  const cellPadding = firstCell.getCellPadding(cellPaddingLocation);
  await context.sync();

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

getNext()

次のセルを取得します。 このセルが最後の ItemNotFound セルの場合は、エラーをスローします。

getNext(): Word.TableCell;

戻り値

注釈

[ API セット: WordApi 1.3 ]

getNextOrNullObject()

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

getNextOrNullObject(): Word.TableCell;

戻り値

注釈

[ API セット: WordApi 1.3 ]

insertColumns(insertLocation, columnCount, values)

セルの列をテンプレートとして使用して、列をセルの左または右に追加します。 これは、統一されたテーブルに適用可能です。 指定すると、文字列値は新しく挿入された行に設定されます。

insertColumns(insertLocation: Word.InsertLocation.before | Word.InsertLocation.after | "Before" | "After", columnCount: number, values?: string[][]): void;

パラメーター

insertLocation

before | after | "Before" | "After"

必須です。 'Before' または 'After' である必要があります。

columnCount

number

必須です。 追加する列の数。

values

string[][]

省略可能な 2 次元配列。 対応する文字列が配列で指定されている場合、セルに設定されます。

戻り値

void

注釈

[ API セット: WordApi 1.3 ]

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[][]

省略可能な 2 次元配列。 対応する文字列が配列で指定されている場合、セルに設定されます。

戻り値

注釈

[ API セット: WordApi 1.3 ]

load(options)

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

load(options?: Word.Interfaces.TableCellLoadOptions): Word.TableCell;

パラメーター

options
Word.Interfaces.TableCellLoadOptions

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

戻り値

load(propertyNames)

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

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

パラメーター

propertyNames

string | string[]

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

戻り値

load(propertyNamesAndPaths)

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

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

パラメーター

propertyNamesAndPaths

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

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

戻り値

set(properties, options)

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

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

パラメーター

properties
Word.Interfaces.TableCellUpdateData

メソッドが呼び出されるオブジェクトのプロパティに等形的に構造化されたプロパティを持つ JavaScript オブジェクト。

options
OfficeExtension.UpdateOptions

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

戻り値

void

set(properties)

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

set(properties: Word.TableCell): void;

パラメーター

properties
Word.TableCell

戻り値

void

setCellPadding(cellPaddingLocation, cellPadding)

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

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

パラメーター

cellPaddingLocation
Word.CellPaddingLocation

必須です。 セルのパディングの場所は、'Top'、'Left'、'Bottom'、または 'Right' である必要があります。

cellPadding

number

必須です。 セルのパディング。

戻り値

void

注釈

[ API セット: WordApi 1.3 ]

setCellPadding(cellPaddingLocationString, cellPadding)

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

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

パラメーター

cellPaddingLocationString

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

必須です。 セルのパディングの場所は、'Top'、'Left'、'Bottom'、または 'Right' である必要があります。

cellPadding

number

必須です。 セルのパディング。

戻り値

void

注釈

[ API セット: WordApi 1.3 ]

split(rowCount, columnCount)

セルを指定した数の行と列に分割します。

split(rowCount: number, columnCount: number): void;

パラメーター

rowCount

number

必須です。 分割する行の数。 基になる行数の割り当て値である必要があります。

columnCount

number

必須です。 分割する列の数。

戻り値

void

注釈

[ API セット: WordApi 1.4 ]

toJSON()

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

toJSON(): Word.Interfaces.TableCellData;

戻り値

track()

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

track(): Word.TableCell;

戻り値

untrack()

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

untrack(): Word.TableCell;

戻り値