OneNote.TableCell class

OneNote テーブル内のセルを表します。

Extends

注釈

[ API セット: OneNoteApi 1.1 ]

プロパティ

cellIndex

その行のセルのインデックスを取得します。 読み取り専用です。

context

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

id

セルの ID を取得します。 読み取り専用です。

paragraphs

TableCell に含まれる Paragraph オブジェクトのコレクションを取得します。 読み取り専用です。

parentRow

セルの親行を取得します。 読み取り専用です。

rowIndex

テーブルのセル行のインデックスを取得します。 読み取り専用です。

shadingColor

セルの網かけの色を取得および設定します。

メソッド

appendHtml(html)

指定された HTML を TableCell の一番下に追加します。

appendImage(base64EncodedImage, width, height)

指定した Image をテーブル セルに追加します。

appendRichText(paragraphText)

指定したテキストをテーブル セルに追加します。

appendTable(rowCount, columnCount, values)

指定された数の行と列を含むテーブルをテーブル セルに追加します。

clear()

セルの内容をクリアします。

load(options)

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

load(propertyNames)

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

load(propertyNamesAndPaths)

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

set(properties, options)

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

set(properties)

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

toJSON()

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

track()

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

untrack()

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

プロパティの詳細

cellIndex

その行のセルのインデックスを取得します。 読み取り専用です。

readonly cellIndex: number;

プロパティ値

number

注釈

[ API セット: OneNoteApi 1.1 ]

context

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

context: RequestContext;

プロパティ値

id

セルの ID を取得します。 読み取り専用です。

readonly id: string;

プロパティ値

string

注釈

[ API セット: OneNoteApi 1.1 ]

paragraphs

TableCell に含まれる Paragraph オブジェクトのコレクションを取得します。 読み取り専用です。

readonly paragraphs: OneNote.ParagraphCollection;

プロパティ値

注釈

[ API セット: OneNoteApi 1.1 ]

parentRow

セルの親行を取得します。 読み取り専用です。

readonly parentRow: OneNote.TableRow;

プロパティ値

注釈

[ API セット: OneNoteApi 1.1 ]

rowIndex

テーブルのセル行のインデックスを取得します。 読み取り専用です。

readonly rowIndex: number;

プロパティ値

number

注釈

[ API セット: OneNoteApi 1.1 ]

shadingColor

セルの網かけの色を取得および設定します。

shadingColor: string;

プロパティ値

string

注釈

[ API セット: OneNoteApi 1.1 ]

メソッドの詳細

appendHtml(html)

指定された HTML を TableCell の一番下に追加します。

appendHtml(html: string): void;

パラメーター

html

string

追加する HTML 文字列です。 OneNote アドイン JavaScript API で サポートされている HTML に関するページを参照してください。

戻り値

void

注釈

[ API セット: OneNoteApi 1.1 ]

await OneNote.run(async (context) => {
    const app = context.application;
    const outline = app.getActiveOutline();
    
    // Queue a command to load outline.paragraphs and their types.
    context.load(outline, "paragraphs, paragraphs/type");
    
    // Run the queued commands, and return a promise to indicate task completion.
    await context.sync();
    
    const paragraphs = outline.paragraphs;
    
    // For each table, get a table cell at row one and column two and add "Hello".
    for (let i = 0; i < paragraphs.items.length; i++) {
        const paragraph = paragraphs.items[i];
        if (paragraph.type == "Table") {
            const table = paragraph.table;
            const cell = table.getCell(1 /*Row Index*/, 2 /*Column Index*/);
            cell.appendHtml("<p>Hello</p>");
        }
    }
    await context.sync();
});

appendImage(base64EncodedImage, width, height)

指定した Image をテーブル セルに追加します。

appendImage(base64EncodedImage: string, width: number, height: number): OneNote.Image;

パラメーター

base64EncodedImage

string

追加する HTML 文字列です。

width

number

オプション。 ポイント単位の幅。 既定値は null で、イメージの幅が使用されます。

height

number

オプション。 ポイント単位の高さ。 既定値は null で、イメージの高さが使用されます。

戻り値

注釈

[ API セット: OneNoteApi 1.1 ]

appendRichText(paragraphText)

指定したテキストをテーブル セルに追加します。

appendRichText(paragraphText: string): OneNote.RichText;

パラメーター

paragraphText

string

追加する HTML 文字列です。

戻り値

注釈

[ API セット: OneNoteApi 1.1 ]

await OneNote.run(async (context) => {
    const app = context.application;
    const outline = app.getActiveOutline();
    const appendedRichText = null;
    
    // Queue a command to load outline.paragraphs and their types.
    context.load(outline, "paragraphs, paragraphs/type");
    
    // Run the queued commands, and return a promise to indicate task completion.
    await context.sync();

    const paragraphs = outline.paragraphs;
    
    // For each table, get a table cell at row one and column two and add "Hello".
    for (let i = 0; i < paragraphs.items.length; i++) {
        const paragraph = paragraphs.items[i];
        if (paragraph.type == "Table") {
            const table = paragraph.table;
            const cell = table.getCell(1 /*Row Index*/, 2 /*Column Index*/);
            appendedRichText = cell.appendRichText("Hello");
        }
    }
    await context.sync();
});

appendTable(rowCount, columnCount, values)

指定された数の行と列を含むテーブルをテーブル セルに追加します。

appendTable(rowCount: number, columnCount: number, values?: string[][]): OneNote.Table;

パラメーター

rowCount

number

必須です。 表の行数。

columnCount

number

必須です。 表の列数。

values

string[][]

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

戻り値

注釈

[ API セット: OneNoteApi 1.1 ]

clear()

セルの内容をクリアします。

clear(): void;

戻り値

void

注釈

[ API セット: OneNoteApi 1.1 ]

load(options)

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

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

パラメーター

options
OneNote.Interfaces.TableCellLoadOptions

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

戻り値

load(propertyNames)

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

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

パラメーター

propertyNames

string | string[]

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

戻り値

await OneNote.run(async (context) => {
    const app = context.application;
    const outline = app.getActiveOutline();
    
    // Queue a command to load outline.paragraphs and their types.
    context.load(outline, "paragraphs, paragraphs/type");
    
    // Run the queued commands, and return a promise to indicate task completion.
    await context.sync();
    const paragraphs = outline.paragraphs;
    
    // For each table, get a table cell at row one and column two.
    for (let i = 0; i < paragraphs.items.length; i++) {
        const paragraph = paragraphs.items[i];
        if (paragraph.type == "Table") {
            const table = paragraph.table;
            const cell = table.getCell(1 /*Row Index*/, 2 /*Column Index*/);
            
            // Queue a command to load the table cell.
            context.load(cell);
            await context.sync();

            console.log("Cell Id: " + cell.id);
            console.log("Cell Index: " + cell.cellIndex);
            console.log("Cell's Row Index: " + cell.rowIndex);
        }
    }
    await context.sync();
});

load(propertyNamesAndPaths)

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

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

パラメーター

propertyNamesAndPaths

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

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

戻り値

set(properties, options)

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

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

パラメーター

properties
OneNote.Interfaces.TableCellUpdateData

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

options
OfficeExtension.UpdateOptions

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

戻り値

void

set(properties)

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

set(properties: OneNote.TableCell): void;

パラメーター

properties
OneNote.TableCell

戻り値

void

toJSON()

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

toJSON(): OneNote.Interfaces.TableCellData;

戻り値

track()

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

track(): OneNote.TableCell;

戻り値

untrack()

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

untrack(): OneNote.TableCell;

戻り値