Show.Table
Show.Table は Presentation モジュール(Office.show(iframe))のオブジェクト型です。メソッド 53 個。
備考
- モジュール: Presentation ·
Office.show(iframe)· 名前空間Show - 取得方法:
Document.findTables(slides, filter)、Slide.findTables(filter)、Slide.insertTable(rowNum, colNum, styleName) - すべてのメソッドは
Promiseを返し、シグネチャは TypeScript 表記です。
メソッド
| メソッド | 説明 |
|---|---|
align(alignType) | 図形をスライド基準で整列します。 |
deleteCol(startCol, endCol) | 指定範囲の列を削除します。 |
deleteRow(startRow, endRow) | 指定範囲の行を削除します。 |
findCells(filter) | 条件に一致するセルの配列を返します。 |
flip(direction) | 図形を上下または左右に反転します。 |
getCell(row, col) | 指定座標のセルを返します。 |
getCells() | すべてのセルを配列で返します。 |
getColCount() | 表の列数を返します。 |
getColumn(colIndex) | 指定列のセルの配列を返します。 |
getColWidth(colIndex) | 指定列の幅を返します。 |
getHeight() | 図形の高さを返します。 |
getPlaceholderType() | 図形の placeholder の種類を返します。 |
getPresetId() | 図形の OOXML preset id (prst) を返します。 |
getRotation() | 図形の回転角度を返します。 |
getRow(rowIndex) | 指定行のセルの配列を返します。 |
getRowCount() | 表の行数を返します。 |
getRowHeight(rowIndex) | 指定行の高さを返します。 |
getStyleName() | 表に適用されたスタイル名を返します。 |
getStyleOption(option) | 表スタイルのオプション(見出し行、縞模様の行など)が有効かどうかを返します。 |
getTransform() | 図形の位置、サイズ、回転の情報を返します。 |
getWidth() | 図形の幅を返します。 |
getX() | 図形の X 座標を返します。 |
getY() | 図形の Y 座標を返します。 |
getZOrderIndex() | 親(スライド、グループの子であればそのグループ)内での図形の z-order の順番を返します。 |
hasText() | 図形がテキストを含んでいるかどうかを返します。 |
insertCol(baseColIndex, position, insertNum) | 基準列の左または右に列を挿入します。 |
insertRow(baseRowIndex, position, insertNum) | 基準行の上または下に行を挿入します。 |
isChart() | Checks whether this handle is of type Chart (type guard for narrowing the union). |
isControl() | Checks whether this handle is of type Control (type guard for narrowing the union). |
isDiagram() | Checks whether this handle is of type Diagram (type guard for narrowing the union). |
isFlippedH() | 図形が左右に反転された状態かどうかを返します。 |
isFlippedV() | 図形が上下に反転された状態かどうかを返します。 |
isGroup() | Checks whether this handle is of type Group (type guard for narrowing the union). |
isImage() | Checks whether this handle is of type Image (type guard for narrowing the union). |
isLine() | Checks whether this handle is of type Line (type guard for narrowing the union). |
isOleObject() | Checks whether this handle is of type OleObject (type guard for narrowing the union). |
isPlaceholder() | 図形が placeholder(タイトル・本文の枠など)かどうかを返します。 |
isShape() | Checks whether this handle is of type Shape (type guard for narrowing the union). |
isTable() | Checks whether this handle is of type Table (type guard for narrowing the union). |
mergeCell(startRow, startCol, endRow, endCol) | 指定範囲のセルを結合します。 |
moveBy(distance) | 図形を現在の位置を基準に x、y だけ相対移動します。 |
reorder(order) | 図形の重なり順(前面へ/背面へ)を変更します。 |
setColWidth(colIndex, newWidth) | 指定列の幅を変更します。 |
setHeight(height) | 表の高さを設定します。 |
setRotation(rotation) | 図形の回転角度を絶対値で設定します。 |
setRowHeight(rowIndex, newHeight) | 指定行の高さを変更します。 |
setStyle(styleName) | 表スタイルを変更します。 |
setStyleOption(option, enabled) | 表スタイルのオプション(見出し行、縞模様の行など)を変更します。 |
setTransform(transform) | 図形の位置・サイズ・回転を一度に設定します。 |
setWidth(width) | 表の幅を設定します。 |
setX(x) | 図形の X 座標を絶対値で設定します。 |
setY(y) | 図形の Y 座標を絶対値で設定します。 |
unmergeCell(startRow, startCol, endRow, endCol) | 指定範囲の結合されたセルを解除します。 |
メソッドの詳細
align(alignType)
図形をスライド基準で整列します。移動できない図形の場合は無視されます。グループの子も、グループ内ではなくスライドを基準に移動します。子がグループの外に出ると、グループは子を含むように一緒に広がります。
align(alignType: AlignType): Promise<void>;
パラメーター
| 名前 | 型 | 説明 |
|---|---|---|
alignType | AlignType | 整列タイプ |
戻り値
none
deleteCol(startCol, endCol)
指定範囲の列を削除します。すべての列を削除することはできません - 1 列の表でその列を削除しようとするとエラーになります。表自体を削除するには Slide.deleteShape を使用します。
deleteCol(startCol: number, endCol: number): Promise<void>;
パラメーター
| 名前 | 型 | 説明 |
|---|---|---|
startCol | number | 削除を開始する列のインデックス(0-based) |
endCol | number | 削除を終了する列のインデックス(0-based、inclusive) |
戻り値
none
deleteRow(startRow, endRow)
指定範囲の行を削除します。すべての行を削除することはできません - 1 行の表でその行を削除しようとするとエラーになります。表自体を削除するには Slide.deleteShape を使用します。
deleteRow(startRow: number, endRow: number): Promise<void>;
パラメーター
| 名前 | 型 | 説明 |
|---|---|---|
startRow | number | 削除を開始する行のインデックス(0-based) |
endRow | number | 削除を終了する行のインデックス(0-based、inclusive) |
戻り値
none
findCells(filter)
条件に一致するセルの配列を返します。複数の条件は AND で結合します。range はセル本体が範囲と重なると一致します(結合の代表セルが範囲外にあっても、セルの一部が範囲内にあれば結果に含まれます)。それ以外の条件は、結合されたセルの代表セルの座標/属性を基準に評価します。
findCells(filter?: CellFilter): Promise<TableCell[]>;
パラメーター
| 名前 | 型 | 説明 |
|---|---|---|
filter(省略可) | CellFilter | 検索条件。null も条件なしとみなします(既定値: all cells) |
戻り値
Promise<TableCell[]> - 条件に一致するセルの一覧
flip(direction)
図形を上下または左右に反転します。現在の反転状態を切り替えるトグルであり、現在反転しているかどうかは isFlippedH()/isFlippedV() で読み取ります。回転できない図形では反転も無視されます。回転された図形は角度も鏡像として一緒に変わります(getRotation() の値が 360 - 元の角度 に変わります)。
flip(direction: FlipDirection): Promise<void>;
パラメーター
| 名前 | 型 | 説明 |
|---|---|---|
direction | FlipDirection | 反転方向 |
戻り値
none
getCell(row, col)
指定座標のセルを返します。結合領域内部の座標を指定すると、その結合領域の代表セルを返します。
getCell(row: number, col: number): Promise<TableCell>;
パラメーター
| 名前 | 型 | 説明 |
|---|---|---|
row | number | 行のインデックス(0-based) |
col | number | 列のインデックス(0-based) |
戻り値
Promise<TableCell> - 該当するセル(範囲外の場合、または表がない場合は null)
getCells()
すべてのセルを配列で返します。結合されたセルは代表セル 1 つのみを含みます。
getCells(): Promise<TableCell[]>;
戻り値
Promise<TableCell[]> - セルの一覧
getColCount()
表の列数を返します。
getColCount(): Promise<number>;
戻り値
Promise<number> - 列数。表がない場合は 0
getColumn(colIndex)
指定列のセルの配列を返します。結合されたセルは代表セル 1 つのみを含みます。
getColumn(colIndex: number): Promise<TableCell[]>;
パラメーター
| 名前 | 型 | 説明 |
|---|---|---|
colIndex | number | 0-based の列のインデックス |
戻り値
Promise<TableCell[]> - 該当する列のセルの一覧
getColWidth(colIndex)
指定列の幅を返します。(setColWidth と対称)
getColWidth(colIndex: number): Promise<number | null>;
パラメーター
| 名前 | 型 | 説明 |
|---|---|---|
colIndex | number | 列のインデックス(0-based) |
戻り値
Promise<number | null> - 幅(px 単位)。範囲外の場合、または表がない場合は null
getHeight()
図形の高さを返します。(setHeight と対称)
getHeight(): Promise<number | null>;
戻り値
Promise<number | null> - 高さ(px 単位)。対象の図形がない場合は null
getPlaceholderType()
図形の placeholder の種類を返します。
getPlaceholderType(): Promise<PlaceholderType | null>;
戻り値
Promise<PlaceholderType | null> - placeholder の種類。placeholder ではない場合、または対象の図形がない場合は null
getPresetId()
図形の OOXML preset id (prst) を返します。
getPresetId(): Promise<string | null>;
戻り値
Promise<string | null> - preset id (prst)。ない場合は null
getRotation()
図形の回転角度を返します。(setRotation と対称)
getRotation(): Promise<number | null>;
戻り値
Promise<number | null> - 回転角度(degree)。対象の図形がない場合は null
getRow(rowIndex)
指定行のセルの配列を返します。結合されたセルは代表セル 1 つのみを含みます。
getRow(rowIndex: number): Promise<TableCell[]>;
パラメーター
| 名前 | 型 | 説明 |
|---|---|---|
rowIndex | number | 0-based の行のインデックス |
戻り値
Promise<TableCell[]> - 該当する行のセルの一覧
getRowCount()
表の行数を返します。
getRowCount(): Promise<number>;
戻り値
Promise<number> - 行数。表がない場合は 0
getRowHeight(rowIndex)
指定行の高さを返します。(setRowHeight と対称)
getRowHeight(rowIndex: number): Promise<number | null>;
パラメーター
| 名前 | 型 | 説明 |
|---|---|---|
rowIndex | number | 行のインデックス(0-based) |
戻り値
Promise<number | null> - 高さ(px 単位)。範囲外の場合、または表がない場合は null
getStyleName()
表に適用されたスタイル名を返します。(setStyle と対称)返された名前はそのまま setStyle に渡せます。ただし、ドキュメントにのみ含まれるスタイルの場合は、doc.getTableStyleNames() の一覧には表示されません。
getStyleName(): Promise<string | null>;
戻り値
Promise<string | null> - 表スタイル名。スタイルがない場合、または名前のないスタイル(ドキュメントに名前が含まれていない場合)の場合は null
getStyleOption(option)
表スタイルのオプション(見出し行、縞模様の行など)が有効かどうかを返します。(setStyleOption と対称)
getStyleOption(option: TableStyleOption): Promise<boolean | null>;
パラメーター
| 名前 | 型 | 説明 |
|---|---|---|
option | TableStyleOption | オプションの種類 |
戻り値
Promise<boolean | null> - 有効かどうか。表または表のプロパティを読み取れない場合は null
getTransform()
図形の位置、サイズ、回転の情報を返します。x/y は反転(flip)の有無に関係なく図形の左上であるため、戻り値を別の図形の setTransform にそのまま渡すと、2 つの図形が同じ位置に配置されます。値は丸めて返されます - サイズは小数第 1 位、位置は整数です。setter も同じ単位で設定するため、インポートしたドキュメントのようにより細かく配置された図形は、値を渡し直すとその分だけ移動します。
getTransform(): Promise<ShapeTransform | null>;
戻り値
Promise<ShapeTransform | null> - 図形の位置・サイズ・回転の情報。対象の図形がない場合(共同編集中の削除など)は null
getWidth()
図形の幅を返します。(setWidth と対称)
getWidth(): Promise<number | null>;
戻り値
Promise<number | null> - 幅(px 単位)。対象の図形がない場合は null
getX()
図形の X 座標を返します。(setX と対称)
getX(): Promise<number | null>;
戻り値
Promise<number | null> - X 座標(px 単位)。対象の図形がない場合は null
getY()
図形の Y 座標を返します。(setY と対称)
getY(): Promise<number | null>;
戻り値
Promise<number | null> - Y 座標(px 単位)。対象の図形がない場合は null
getZOrderIndex()
親(スライド、グループの子であればそのグループ)内での図形の z-order の順番を返します。0 が最背面で、大きいほど前面です。
getZOrderIndex(): Promise<number | null>;
戻り値
Promise<number | null> - z-order の順番。対象の図形がない場合は null
hasText()
図形がテキストを含んでいるかどうかを返します。空白のみの場合や空の段落が 2 つ以上ある場合(改行のみを入力した状態)は true、空の段落が 1 つだけの場合は false です。図形レベルのテキストを持たない種類(表・グループ・グラフ)は常に false です。(表はセル単位で照会します)
hasText(): Promise<boolean | null>;
戻り値
Promise<boolean | null> - テキストの有無。対象の図形がない場合は null
insertCol(baseColIndex, position, insertNum)
基準列の左または右に列を挿入します。新しい列は基準列の書式を継承します。
insertCol(baseColIndex: number, position: InsertPosition, insertNum: number): Promise<void>;
パラメーター
| 名前 | 型 | 説明 |
|---|---|---|
baseColIndex | number | 挿入の基準となる列のインデックス(0-based) |
position | InsertPosition | 挿入位置(InsertPosition.LEFT: 基準列の左、InsertPosition.RIGHT: 基準列の右) |
insertNum | number | 挿入する列数 |
戻り値
none
insertRow(baseRowIndex, position, insertNum)
基準行の上または下に行を挿入します。新しい行は基準行の書式を継承します。
insertRow(baseRowIndex: number, position: InsertPosition, insertNum: number): Promise<void>;
パラメーター
| 名前 | 型 | 説明 |
|---|---|---|
baseRowIndex | number | 挿入の基準となる行のインデックス(0-based) |
position | InsertPosition | 挿入位置(InsertPosition.ABOVE: 基準行の上、InsertPosition.BELOW: 基準行の下) |
insertNum | number | 挿入する行数 |
戻り値
none
isChart()
Checks whether this handle is of type Chart (type guard for narrowing the union). Checks the SDK handle's internal discriminator synchronously - no postMessage round trip, no await needed.
isChart(): Promise<this is Chart>;
戻り値
Promise<this is Chart>
isControl()
Checks whether this handle is of type Control (type guard for narrowing the union). Checks the SDK handle's internal discriminator synchronously - no postMessage round trip, no await needed.
isControl(): Promise<this is Control>;
戻り値
Promise<this is Control>
isDiagram()
Checks whether this handle is of type Diagram (type guard for narrowing the union). Checks the SDK handle's internal discriminator synchronously - no postMessage round trip, no await needed.
isDiagram(): Promise<this is Diagram>;
戻り値
Promise<this is Diagram>
isFlippedH()
図形が左右に反転された状態かどうかを返します。(flip(FlipDirection.HORIZONTAL) を呼び出すとこの値が反転します)
isFlippedH(): Promise<boolean | null>;
戻り値
Promise<boolean | null> - 左右反転の有無。対象の図形がない場合は null
isFlippedV()
図形が上下に反転された状態かどうかを返します。(flip(FlipDirection.VERTICAL) を呼び出すとこの値が反転します)
isFlippedV(): Promise<boolean | null>;
戻り値
Promise<boolean | null> - 上下反転の有無。対象の図形がない場合は null
isGroup()
Checks whether this handle is of type Group (type guard for narrowing the union). Checks the SDK handle's internal discriminator synchronously - no postMessage round trip, no await needed.
isGroup(): Promise<this is Group>;
戻り値
Promise<this is Group>
isImage()
Checks whether this handle is of type Image (type guard for narrowing the union). Checks the SDK handle's internal discriminator synchronously - no postMessage round trip, no await needed.
isImage(): Promise<this is Image>;
戻り値
Promise<this is Image>
isLine()
Checks whether this handle is of type Line (type guard for narrowing the union). Checks the SDK handle's internal discriminator synchronously - no postMessage round trip, no await needed.
isLine(): Promise<this is Line>;
戻り値
Promise<this is Line>
isOleObject()
Checks whether this handle is of type OleObject (type guard for narrowing the union). Checks the SDK handle's internal discriminator synchronously - no postMessage round trip, no await needed.
isOleObject(): Promise<this is OleObject>;
戻り値
Promise<this is OleObject>
isPlaceholder()
図形が placeholder(タイトル・本文の枠など)かどうかを返します。
isPlaceholder(): Promise<boolean | null>;
戻り値
Promise<boolean | null> - placeholder かどうか。対象の図形がない場合は null
isShape()
Checks whether this handle is of type Shape (type guard for narrowing the union). Checks the SDK handle's internal discriminator synchronously - no postMessage round trip, no await needed.
isShape(): Promise<this is Shape>;
戻り値
Promise<this is Shape>
isTable()
Checks whether this handle is of type Table (type guard for narrowing the union). Checks the SDK handle's internal discriminator synchronously - no postMessage round trip, no await needed.
isTable(): Promise<this is Table>;
戻り値
Promise<this is Table>
mergeCell(startRow, startCol, endRow, endCol)
指定範囲のセルを結合します。範囲に一部だけかかる既存の結合セルがある場合は、そのセルをすべて含むように範囲を広げて結合します。
mergeCell(startRow: number, startCol: number, endRow: number, endCol: number): Promise<void>;
パラメーター
| 名前 | 型 | 説明 |
|---|---|---|
startRow | number | 結合を開始する行のインデックス(0-based) |
startCol | number | 結合を開始する列のインデックス(0-based) |
endRow | number | 結合を終了する行のインデックス(0-based、inclusive) |
endCol | number | 結合を終了する列のインデックス(0-based、inclusive) |
戻り値
none
moveBy(distance)
図形を現在の位置を基準に x、y だけ相対移動します。(絶対座標の設定は setX / setY)
moveBy(distance: ShapeMoveDistance): Promise<void>;
パラメーター
| 名前 | 型 | 説明 |
|---|---|---|
distance | ShapeMoveDistance | 移動量(px 単位) |
戻り値
none
reorder(order)
図形の重なり順(前面へ/背面へ)を変更します。すでに目標の位置にあり変更がない場合は無視されます。
reorder(order: ShapeZOrder): Promise<void>;
パラメーター
| 名前 | 型 | 説明 |
|---|---|---|
order | ShapeZOrder | 順序変更タイプ |
戻り値
none
setColWidth(colIndex, newWidth)
指定列の幅を変更します。列は最小幅(セルの左右の余白を含む)より狭くなりません。
setColWidth(colIndex: number, newWidth: number): Promise<void>;
パラメーター
| 名前 | 型 | 説明 |
|---|---|---|
colIndex | number | 列のインデックス(0-based) |
newWidth | number | 新しい幅(px 単位)。colIndex が表の列数を超える場合は無視されます |
戻り値
none
setHeight(height)
表の高さを設定します。すべての行の高さを同じ比率で変更します。サイズ変更できない表(グループ内の表など)の場合は無視されます。
setHeight(height: number): Promise<void>;
パラメーター
| 名前 | 型 | 説明 |
|---|---|---|
height | number | 高さ(px 単位、小数第 1 位に丸め) |
戻り値
none
setRotation(rotation)
図形の回転角度を絶対値で設定します。回転できない図形の場合は無視されます。(getRotation と対称)
setRotation(rotation: number): Promise<void>;
パラメーター
| 名前 | 型 | 説明 |
|---|---|---|
rotation | number | 回転角度(degree) |
戻り値
none
setRowHeight(rowIndex, newHeight)
指定行の高さを変更します。
setRowHeight(rowIndex: number, newHeight: number): Promise<void>;
パラメーター
| 名前 | 型 | 説明 |
|---|---|---|
rowIndex | number | 行のインデックス(0-based) |
newHeight | number | 新しい高さ(px 単位)。rowIndex が表の行数を超える場合は無視されます |
戻り値
none
setStyle(styleName)
表スタイルを変更します。(getStyleName と対称)
setStyle(styleName: string): Promise<void>;
パラメーター
| 名前 | 型 | 説明 |
|---|---|---|
styleName | string | 表スタイル名(doc.getTableStyleNames() の結果または getStyleName() の値、大文字と小文字を区別しない) |
戻り値
none
setStyleOption(option, enabled)
表スタイルのオプション(見出し行、縞模様の行など)を変更します。(getStyleOption と対称)
setStyleOption(option: TableStyleOption, enabled: boolean): Promise<void>;
パラメーター
| 名前 | 型 | 説明 |
|---|---|---|
option | TableStyleOption | オプションの種類 |
enabled | boolean | 有効にするかどうか |
戻り値
none
setTransform(transform)
図形の位置・サイズ・回転を一度に設定します。getTransform() の戻り値をそのまま渡せます。(getTransform と対称)値を指定したフィールドだけをサイズ→位置→回転の順に適用し、省略したフィールドは現在の値を維持します。各フィールドは個別の setter と同様に、該当する操作(サイズ/移動/回転)ができない図形では無視されます。
setTransform(transform?: Partial<ShapeTransform>): Promise<void>;
パラメーター
| 名前 | 型 | 説明 |
|---|---|---|
transform(省略可) | Partial<ShapeTransform> | 位置/サイズ(px)· 回転(degree)。省略すると何も変更しません |
戻り値
none
setWidth(width)
表の幅を設定します。すべての列の幅を同じ比率で変更し、列は最小幅(セルの左右の余白を含む)より狭くなりません。サイズ変更できない表(グループ内の表など)の場合は無視されます。
setWidth(width: number): Promise<void>;
パラメーター
| 名前 | 型 | 説明 |
|---|---|---|
width | number | 幅(px 単位、小数第 1 位に丸め) |
戻り値
none
setX(x)
図形の X 座標を絶対値で設定します。移動できない図形の場合は無視されます。(相対移動は moveBy)
setX(x: number): Promise<void>;
パラメーター
| 名前 | 型 | 説明 |
|---|---|---|
x | number | X 座標(px 単位、整数に丸め) |
戻り値
none
setY(y)
図形の Y 座標を絶対値で設定します。移動できない図形の場合は無視されます。
setY(y: number): Promise<void>;
パラメーター
| 名前 | 型 | 説明 |
|---|---|---|
y | number | Y 座標(px 単位、整数に丸め) |
戻り値
none
unmergeCell(startRow, startCol, endRow, endCol)
指定範囲の結合されたセルを解除します。
unmergeCell(startRow: number, startCol: number, endRow: number, endCol: number): Promise<void>;
パラメーター
| 名前 | 型 | 説明 |
|---|---|---|
startRow | number | 解除を開始する行のインデックス(0-based) |
startCol | number | 解除を開始する列のインデックス(0-based) |
endRow | number | 解除を終了する行のインデックス(0-based、inclusive) |
endCol | number | 解除を終了する列のインデックス(0-based、inclusive) |
戻り値
none