I have adjusted the code to the following, but although the Col1/2 and Row1/2 properties are read and write, it does not appear that they are affecting the generated xlsx at all. Am I going about this the wrong way, or is this a bug?
Code: Select all
procedure RocAddNoteToCell(aRow, aCol: Integer; aText: String);
var
heightInRows: integer;
comment : TXc12Comment;
begin
if aText = '' then
exit;
//Long text needs more rows, provide an extra row for every 80 characters.
heightInRows := 1 + (Length(aText) div 80);
XLS[0].Comments.Add(aCol,aRow,aText);
comment := XLS[0].Comments.Find(aCol,aRow).Xc12Comment;
with comment do begin
Col1 := aCol+1;
Row1 := aRow;
Col2 := aCol+6;
Row2 := aRow+heightInRows;
Color := TXc12DefaultIndexColorPalette[integer(xcPaleGreen)];
end;
end;
Version 4 code:
Code: Select all
procedure RocAddNoteToCell(aRow, aCol: Integer; aText: String);
var heightInRows : integer;
begin
if aText = '' then
exit;
//Long text needs more rows, provide an extra row for every 80 characters.
heightInRows := 1 + (Length(aText) div 80);
with XLS.Sheets[0].DrawingObjects.Notes.Add do begin
CellCol := aCol;
CellRow := aRow;
Col1 := aCol+1;
Row1 := aRow;
Col2 := aCol+6;
Row2 := aRow+heightInRows;
FillColor := TColor(TDefaultExcelColorPalette[integer(xcPaleGreen)]);
Text := aText;
end;
end;