SheetXL - v0.8.0-beta.9+sites.210.e2d420901
    Preparing search index...

    Interface IComment

    A comment on a cell: the root of a thread, with its replies, or a note.

    Follows Office Scripts' Comment: one per cell, the thread's root, resolved as a whole, with replies (IComment.IReply) that borrow its cell. A note — Excel's older yellow box — is a comment that says so: it has no replies, no resolved state and no creation date, and its content may carry formatting runs where a thread's is plain text.

    Anchored to its cell, so it follows a row or column insert or delete and is deleted when its cell is.

    A note is also the content of a movable: the box it is shown in.

    interface IComment {
        isIAnchored: true;
        isIComment: true;
        acceptFlip?(flip: Flip): Flip;
        acceptRotation?(degrees: number): number;
        addListeners(
            listeners: IComment.IListeners,
            options?: IListener.Options,
        ): Remove;
        addReply(content: IComment.Content, options?: AddReplyOptions): IReply;
        close(): void;
        delete(options?: ITransaction.OperationOptions): void;
        getAnchorType?(): IAnchored.Type;
        getAuthor(): IPerson | null;
        getContent(): string;
        getCreationDate(): Date | null;
        getDescription(): string | null;
        getId(): string;
        getMovable(): IMovable | null;
        getName?(): string | null;
        getRange(options?: ICellRange.GetRangeOptions): ICellRange;
        getRanges(options?: ICellRange.GetRangeOptions): ICellRanges;
        getReplies(): IReply[];
        getReply(id: string): IReply | null;
        getRichContent(): IRichText.JSON | null;
        getSheet(): ISheet;
        getType(): string;
        getTypeDescription(): string;
        isClosed(): boolean;
        isDeleted(): boolean;
        isNote(): boolean;
        isProtected(): boolean;
        isResolved(): boolean;
        setContent(
            content: IComment.Content,
            options?: ITransaction.OperationOptions,
        ): this;
        setDescription(description: string | null): this;
        setName?(name: string): this;
        setResolved(
            resolved: boolean,
            options?: ITransaction.OperationOptions,
        ): this;
        toJSON(): IComment.JSON | null;
        update(
            properties: Partial<IComment.Properties> | IComment,
            options?: ITransaction.OperationOptions,
        ): this;
    }

    Hierarchy (View Summary)

    Index
    isIAnchored: true

    For runtime type checking.

    isIComment: true

    For runtime type checking.

    • The flip this content takes when asked to mirror as flip states.

      Parameters

      Returns Flip

      Defined by content that can be mirrored, such as a shape or a picture; absent, the content cannot: a frame dragged through its opposite edge is moved there but not mirrored, as Excel does with a chart. Must be pure, as acceptRotation is. A connector may accept each axis on its own.

    • The rotation this content takes when asked to turn by degrees, clockwise.

      Parameters

      • degrees: number

      Returns number

      Defined by content that can be turned, such as a shape or a picture; absent, the content cannot and no rotate handle is offered. Must be pure: it is asked throughout a gesture to draw its preview, and the answer is what the movable stores.

    • Similar to delete but cleans resources and can't be undone.

      Returns void

    • The person who wrote the comment, or null if the workbook does not know them.

      Returns IPerson | null

    • The content as plain text.

      Returns string

      A note's formatting runs are joined; see getRichContent for them.

    • When the comment was written, or null for a note, which Excel does not date.

      Returns Date | null

    • Returns the alternative text used by assistive technologies, or null if none has been set.

      Returns string | null

    • The comment's identifier, unique within the workbook.

      Returns string

    • The box a note is shown in, or null for a threaded comment, which has none.

      Returns IMovable | null

      The box is an ordinary movable: it is selected, moved and resized like a picture's, and is among the sheet's getMovables(). Its content is this comment.

      • Placement. A box that has not been moved sits where Excel puts a new note, beside its cell, and stores nothing. Moving or resizing it stores where it is, relative to its cell, so a note copied to another cell keeps its box beside it.
      • Shown or on hover. isHidden() is true for a box that appears only while its cell is pointed at, which is how a note starts and which a view decides. setHidden(false) keeps it on the sheet.

      A reply converts a note to a threaded comment, and its box goes with it.

      const note = sheet.getComments().add('B2', 'Check this', { asNote: true });
      const box = note.getMovable();
      box.setHidden(false); // always shown
      box.setBounds({ width: 240 });
    • The name of the anchor or null if it has none.

      Returns string | null

    • Returns the ranges this object is anchored to, in authored order.

      Parameters

      Returns ICellRanges

      • Never null. An item whose last range was removed by a row/column delete returns an invalid ranges — ask ICellRanges.isInvalid, the same contract as ITable.getDataRange.
      • This is the general accessor. Most anchored types hold exactly one range and declare their own getRange() for it, but data validations, conditional formats and protected ranges are authored as several, and any single range can become several when a delete splits it.
    • The replies, oldest first.

      Returns IReply[]

    • Returns the reply with the given id, or null if there is none.

      Parameters

      • id: string

      Returns IReply | null

    • The content with its formatting runs, or null when it is plain text.

      Returns IRichText.JSON | null

    • The sheet the comment is on.

      Returns ISheet

    • 'note' for a note, 'comment' for a threaded comment.

      Returns string

    • Returns a label for the kind of content, such as Chart or Picture.

      Returns string

    • Returns if the model has been closed

      Returns boolean

    • Returns if the model has been deleted

      Returns boolean

    • If the anchor is unable to be modified.

      Returns boolean

    • Whether the thread is resolved.

      Returns boolean

      Always false for a note.

    • Set the alternative text used by assistive technologies.

      Parameters

      • description: string | null

      Returns this

    • Set the name.

      Parameters

      • name: string

        The name of the content.

      Returns this

    • Returns IComment.JSON | null

      The current state as a JSON object, or null if there is no state.