Page 1 of 1

Alter the comment box size isn't working

Posted: Thu Jan 29, 2015 12:53 am
by mwhiting
I'm upgrading from ver 4 in which I was able to specify the size of the comment box when adding a comment. Using version 50.20.41 I am struggling to determine how to specify the size.

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;
I also attempted using AsSimpleTags and adjusting the xml directly, but it doesn't work either. GetAsSimpleTags just returns an empty string and SetAsSimpleTags treats the string passed in as the text of the comment instead of as the xml it should be and setting FVML to it. I'd prefer not to adjust the xml anyway, so I don't mind AsSimpleTags being broken.

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;