0

I'm using Gembox 37.3.30.1030. I'm adding comments to cells which sometimes are not displayed properly due to a small comment size. I don't see any properties which can resize the comment. Can anyone help? Thanks!

Shlomi
  • 19

1 Answers1

0

EDIT:

In the newer versions of GemBox.Spreadsheet there is an ExcelComment.AutoFit() method that you can use.

ORIGINAL:

You can define the ExcelComment's size by specifying TopLeftCell and BottomRightCell.
For example:

ExcelFile workbook = new ExcelFile();
ExcelWorksheet worksheet = workbook.Worksheets.Add("Sheet1");
ExcelComment comment = worksheet.Cells["B2"].Comment;

comment.Text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.";
comment.TopLeftCell = new AnchorCell(worksheet.Columns[3], worksheet.Rows[5], true);
comment.BottomRightCell = new AnchorCell(worksheet.Columns[6], worksheet.Rows[20], false);
//comment.IsVisible = true;

workbook.Save("Sample.xlsx");

Note that there is no auto-fitting or auto-sizing or anything similar for comments content, so you'll have to set the size yourself.
You could try creating some rough approximation that would adjust the comment's size based on only the number of lines or number of characters in the comment's text.

FYI the last version of GemBox.Spreadsheet 3.7 is 37.3.30.1189, you can download it from here.

Mario Z
  • 4,328
  • 2
  • 24
  • 38