HotXLS Docs

TXLSXComments / TXLSXComment classes

Cell-comment support on a TXLSXWorksheet. Each entry attaches an author plus a free-text body to a cell. SaveAs emits xl/commentsN.xml with a deduplicated author list and a companion xl/drawings/vmlDrawingN.vml so Excel can render the comment balloons; Open reads the comments XML back into the collection. Declared in lxHandleX.

TXLSXComment declaration

type
  TXLSXComment = class
    constructor Create(ARow, ACol: Integer; const AAuthor, AText: WideString);
    property Row: Integer;
    property Col: Integer;
    property Author: WideString;
    property Text: WideString;
  end;
      

TXLSXComment members

Row, Col 1-based cell anchor coordinates.
Author Comment author name. Distinct names are written once into the workbook-level <authors> list and referenced by authorId.
Text Comment body text. Written as a single <text><r><t> run on SaveAs and flattened from one or more runs on Open.

TXLSXComments declaration

type
  TXLSXComments = class
    function Add(ARow, ACol: Integer; const AText: WideString): Integer; overload;
    function Add(ARow, ACol: Integer; const AText, AAuthor: WideString): Integer; overload;
    procedure Clear;
    property Count: Integer;
    property Items[Index: Integer]: TXLSXComment; default;
  end;
      

TXLSXComments members

Add(Row, Col, Text) Adds an unsigned comment (empty author). Returns the new entry index.
Add(Row, Col, Text, Author) Adds a comment with an explicit author name.
Count Number of comments on the worksheet.
Items[Index] Comment at the given 0-based index. Declared as the default property.
Clear Removes and frees every comment.

Example

var
  ws: TXLSXWorksheet;
begin
  ws := Workbook.Sheets.Add('Reviews');

  ws.Cells.Item[1, 1].Value := 'Q1 revenue';
  ws.AddComment(1, 1, 'Numbers still pending review', 'Kevin');

  // Equivalent through the collection:
  ws.Comments.Add(2, 1, 'Auto-generated draft');
end;
    

See also