HotXLS-dokumentation

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 så Excel kan gengive kommentarballonerne; Open læser kommentar-XML'en tilbage i samlingen. Erklæret i 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 medlemmer

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
    constructor Create;
    destructor Destroy; override;
    function Add(ARow, ACol: Integer; const AText: WideString): Integer; overload;
    function Add(ARow, ACol: Integer; const AText, AAuthor: WideString): Integer; overload;
    function IndexOfCell(ARow, ACol: Integer): Integer;
    function FindAt(ARow, ACol: Integer): TXLSXComment;
    function DeleteAt(ARow, ACol: Integer): Boolean;
    function DeleteInRange(ARow1, ACol1, ARow2, ACol2: Integer): Integer;
    procedure Delete(Index: Integer);
    procedure Clear;
    property Count: Integer;
    property Items[Index: Integer]: TXLSXComment; default;
  end;
      

TXLSXComments medlemmer

Add(Row, Col, Text) Adds an unsigned comment (empty author). Returnerer the new entry index
Add(Row, Col, Text, Author) Adds a comment with an explicit author name
IndexOfCell(Row, Col) Returnerer the 0-based index of the comment anchored at the 1-based cell coordinate, or -1 when the cell has no comment
FindAt(Row, Col) Returnerer the comment object anchored at the cell, or nil when no comment is present
DeleteAt(Row, Col) Deletes the comment anchored at the cell and returns True; returns False when no matching comment exists
DeleteInRange(Row1, Col1, Row2, Col2) Sletter alle kommentarer, hvis anker ligger inden for det inklusive 1-baserede celleområde, og returnerer antallet af fjernede. Omvendte koordinater accepteres
Delete(Index) Deletes the comment at the specified 0-based collection index
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

Eksempel

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');

  if ws.Comments.IndexOfCell(1, 1) >= 0 then
    ws.Comments.DeleteAt(1, 1);
end;
    

Se også