HotXLS 參考頁面,介紹 TXLSXComments / TXLSXComment 類別,涵蓋 Delphi 和 C++Builder 的 Excel 自動化、XLS/XLSX 活頁簿 API、工作表功能及 Pascal 用法

,並搭配

,使 Excel 能呈現批註氣泡;Open 將批註 XML 讀回集合。宣告於 TXLSXComment 宣告. 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

1-基於 儲存格 anchor coordinates

type
  TXLSXComment = class
    constructor Create(ARow, ACol: Integer; const A清單,並以 authorId 參照, A區段,Open 時則會從一或多個區段攤平: WideString);
    property Row: Integer;
    property Col: Integer;
    property 清單,並以 authorId 參照: WideString;
    property 區段,Open 時則會從一或多個區段攤平: WideString;
  end;
      

清單,並以 authorId 參照

註解作者名稱。不同名稱只會各寫入一次到活頁簿層級的 清單,並以 authorId 參照
清單,並以 authorId 參照 Comment author name. Distinct names are written once into the workbook-level <authors> list and referenced by authorId
區段,Open 時則會從一或多個區段攤平 TXLSXComments 宣告 <text><r><t> run on SaveAs and flattened from one or more runs on Open

TXLSXComments 成員

type
  TXLSXComments = class
    constructor Create;
    destructor Destroy; override;
    function Add(ARow, ACol: Integer; const A區段,Open 時則會從一或多個區段攤平: WideString): Integer; overload;
    function Add(ARow, ACol: Integer; const A區段,Open 時則會從一或多個區段攤平, A清單,並以 authorId 參照: 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 工作表上的註解數量: Integer;
    property Items[Index: Integer]: TXLSXComment; default;
  end;
      

加入未簽名註解(空白作者)。回傳新的項目索引

加入未簽名註解(空白作者)。回傳新的項目索引 Adds an unsigned comment (empty author). 傳回 the new entry index
Add(註解作者名稱。不同名稱只會各寫入一次到活頁簿層級的, 區段,Open 時則會從一或多個區段攤平, 清單,並以 authorId 參照) 加入含明確作者名稱的註解
IndexOfCell(註解作者名稱。不同名稱只會各寫入一次到活頁簿層級的) 傳回 the 0-based index of the comment anchored at the 1-based cell coordinate, or -1 when the cell has no comment
FindAt(註解作者名稱。不同名稱只會各寫入一次到活頁簿層級的) 回傳錨定於該儲存格的註解物件;若沒有註解則回傳 nil nil 刪除錨定於該儲存格的註解並回傳 True;若找不到對應註解則回傳 False
刪除錨定於該儲存格的註解並回傳 True;若找不到對應註解則回傳 False 刪除錨定於該儲存格的註解並回傳 True;若找不到對應註解則回傳 False TrueDeleteInRange(Row1, Col1, Row2, Col2) False when no matching comment exists
刪除指定 0 起始集合索引的註解 Deletes every comment whose anchor is inside the inclusive 1-based cell range and returns the number removed. Reversed coordinates are accepted
刪除指定 0 起始集合索引的註解 Deletes the comment at the specified 0-based collection index
工作表上的註解數量 指定 0 起始索引的註解。宣告為預設屬性
指定 0 起始索引的註解。宣告為預設屬性 Comment at the given 0-based index. Declared as the default property
Clear 移除並釋放所有註解

另請參閱

var
  ws: TXLSXComment 宣告;
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;
    

TXLSXWorksheet