Ondersteuning voor celcommentaar op een
TXLSXWorksheet. Elk
item koppelt een auteur plus een vrije-tekst-inhoud aan een cel. SaveAs schrijft
xl/commentsN.xml met een gededupliceerde auteurslijst en een
bijbehorend
xl/drawings/vmlDrawingN.vml zodat Excel de
commentaarballonnen kan weergeven; Open leest de comments-XML terug in de
verzameling. Gedeclareerd 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 en
referenced by authorId |
| Text |
Comment body text. Written as a single
<text><r><t> run on SaveAs en
flattened from one of 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 members
| Add(Row, Col, Text) |
Adds an unsigned comment (empty author). Retourneert
the new entry index |
| Add(Row, Col, Text, Author) |
Adds a comment with an explicit author name |
| IndexOfCell(Row, Col) |
Retourneert de op 0 gebaseerde index van de opmerking die verankerd is
op de op 1 gebaseerde celcoördinaat, of -1 wanneer de cel
geen opmerking heeft |
| FindAt(Row, Col) |
Retourneert het opmerkingobject dat aan de cel verankerd is, of
nil wanneer er geen opmerking is |
| DeleteAt(Row, Col) |
Verwijdert de opmerking die aan de cel verankerd is en geeft
True terug; geeft False terug wanneer geen overeenkomende opmerking
bestaat |
| DeleteInRange(Row1, Col1, Row2, Col2) |
Verwijdert elke opmerking waarvan het anker binnen het
inclusieve 1-based celbereik ligt en geeft het aantal verwijderde terug. Omgekeerde
coördinaten worden geaccepteerd |
| 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 eigenschap |
| Clear |
Removes en frees every comment |
Voorbeeld
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;
Zie ook