Excel.Comment class

ブック内のコメントを表します。

Extends

プロパティ

authorEmail

コメント作成者のメール アドレスを取得します。

authorName

コメント作成者の名前を取得します。

content

コメントの内容。 文字列はプレーン テキストです。

context

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

creationDate

コメントの作成日時を取得します。 コメントに作成日がないため、コメントがメモから変換された場合は null を返します。

id

コメント識別子を指定します。

replies

コメントに関連付けられている返信オブジェクトのコレクションを表します。

メソッド

delete()

コメントと接続されているすべての返信を削除します。

getLocation()

このコメントが配置されているセルを取得します。

load(options)

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

load(propertyNames)

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

load(propertyNamesAndPaths)

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

set(properties, options)

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

set(properties)

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

toJSON()

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

プロパティの詳細

authorEmail

コメント作成者のメール アドレスを取得します。

readonly authorEmail: string;

プロパティ値

string

注釈

API セット: ExcelApi 1.10

authorName

コメント作成者の名前を取得します。

readonly authorName: string;

プロパティ値

string

注釈

API セット: ExcelApi 1.10

content

コメントの内容。 文字列はプレーン テキストです。

content: string;

プロパティ値

string

注釈

API セット: ExcelApi 1.10

例

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/comment-basics.yaml

await Excel.run(async (context) => {
    const sheet = context.workbook.worksheets.getItem("Comments");
    const comment = sheet.comments.getItemAt(0);
    comment.content = "PLEASE add headers here.";
    await context.sync();
});

context

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

context: RequestContext;

プロパティ値

creationDate

コメントの作成日時を取得します。 コメントに作成日がないため、コメントがメモから変換された場合は null を返します。

readonly creationDate: Date;

プロパティ値

Date

注釈

API セット: ExcelApi 1.10

id

コメント識別子を指定します。

readonly id: string;

プロパティ値

string

注釈

API セット: ExcelApi 1.10

replies

コメントに関連付けられている返信オブジェクトのコレクションを表します。

readonly replies: Excel.CommentReplyCollection;

プロパティ値

注釈

API セット: ExcelApi 1.10

例

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/comment-replies.yaml

await Excel.run(async (context) => {
    // Adds a reply to the first comment in this worksheet.
    const sheet = context.workbook.worksheets.getItem("Comments");
    const comment: Excel.Comment = sheet.comments.getItemAt(0);
    comment.replies.add("Add content to this worksheet.");
    await context.sync();
});

メソッドの詳細

delete()

コメントと接続されているすべての返信を削除します。

delete(): void;

返品

void

注釈

API セット: ExcelApi 1.10

例

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/comment-basics.yaml

await Excel.run(async (context) => {
    context.workbook.comments.getItemByCell("Comments!A2").delete();
    await context.sync();
});

getLocation()

このコメントが配置されているセルを取得します。

getLocation(): Excel.Range;

返品

注釈

API セット: ExcelApi 1.10

load(options)

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

load(options?: Excel.Interfaces.CommentLoadOptions): Excel.Comment;

パラメーター

options
Excel.Interfaces.CommentLoadOptions

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

返品

load(propertyNames)

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

load(propertyNames?: string | string[]): Excel.Comment;

パラメーター

propertyNames

string | string[]

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

返品

例

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/12-comments-and-notes/comment-basics.yaml

await Excel.run(async (context) => {
    const comment = context.workbook.comments.getItemByCell("Comments!A2");
    comment.load(["authorEmail", "authorName", "creationDate"]);
    await context.sync();

    console.log(`${comment.creationDate.toDateString()}: ${comment.authorName} (${comment.authorEmail})`);
    await context.sync();
});

load(propertyNamesAndPaths)

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

load(propertyNamesAndPaths?: {
            select?: string;
            expand?: string;
        }): Excel.Comment;

パラメーター

propertyNamesAndPaths

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

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

返品

set(properties, options)

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

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

パラメーター

properties
Excel.Interfaces.CommentUpdateData

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

options
OfficeExtension.UpdateOptions

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

返品

void

set(properties)

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

set(properties: Excel.Comment): void;

パラメーター

properties
Excel.Comment

返品

void

toJSON()

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

toJSON(): Excel.Interfaces.CommentData;

返品