Comment question

Hi all,

Is there any way to make part of the text bold in the comment's note?

I know that there you can set the Font.IsBold=true on the Comment object but it applies for all the note, but i need to do it on part of the note.

Thanks,

Ofir

Hi,

Thanks for considering Aspose.

Yes, you can do it, you may use Comment.Characters attribute. Please check the following sample code for your need.

Sample code:

Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
Comments comments = worksheet.Comments;
int index = comments.Add("B2");
Comment comment = comments[index];
comment.Note = "This is my Comment";
comment.Characters(0, 10).Font.IsBold = false;
comment.Characters(11, 7).Font.Name = "Tahoma";
comment.Characters(11, 7).Font.Size = 15;
comment.Characters(11, 7).Font.Color = Color.Red;
comment.Characters(11, 7).Font.IsBold = true;
comment.Characters(11, 7).Font.IsItalic = true;
workbook.Save("f:\\test\\testcomments_chars.xls");

Thank you.

Great.

Thanks.

Hi Amjad,

I have addtional question on this issue.

I'm getting a very strange behavior with comments that are applied on merged cells I have in my worksheet.

I'm applying the comment on one of the cells in the merged cells (the first one. Is there any way to it on all the cells in code?) and I also have some cells below that contain drop down list (using list data validation).

When I click on one of the drop downs the comment from the cell above is opened (where it was supposed to open only when going over the merged cell).

Is this a bug or I'm doing something wrong?

Thank you,

Ofir

Ofir:

Hi Amjad,

I have addtional question on this issue.

I'm getting a very strange behavior with comments that are applied on merged cells I have in my worksheet.

I'm applying the comment on one of the cells in the merged cells (the first one. Is there any way to it on all the cells in code?) and I also have some cells below that contain drop down list (using list data validation).

When I click on one of the drop downs the comment from the cell above is opened (where it was supposed to open only when going over the merged cell).

Is this a bug or I'm doing something wrong?

Thank you,

Ofir

Another thing,

It seems that it hapnnes on non merged cells as well and it looks like the list data validation has something to do with the problem becuase if I remove it the problem doesnt occur.

Ofir

Hi Ofir,

I'm applying the comment on one of the cells in the merged cells (the first one. Is there any way to it on all the cells in code?)

Well, you may try to use Cells.MergedCells attribute to get the ArrayList collection and then define a separate CellArea based on each arraylist.

e.g..,

Cells cells = worksheet.Cells;
ArrayList al = new ArrayList();
al = cells.MergedCells;
CellArea ca;
int frow,fcol,erow,ecol;

for (int i = 0;i< al.Count;i++)
{
ca = new CellArea();
ca = (CellArea)al[i];
frow = ca.StartRow;
fcol = ca.StartColumn;
erow = ca.EndRow;
ecol = ca.EndColumn;

//Your code goes here.

}

When I click on one of the drop downs the comment from the cell above is opened (where it was supposed to open only when going over the merged cell). Is this a bug or I'm doing something wrong?

Another thing,

It seems that it hapnnes on non merged cells as well and it looks like the list data validation has something to do with the problem becuase if I remove it the problem doesnt occur.

Could you give us more details and post your template file, created file and sample code here, we will check it soon. Also, tell us which version of the component you are using.

Thank you.

Hi Amjad,

I've just tried using the code above but it seems that the Comment object doesnt contain a defintion for Characters.

I'm using dll version 4.4.3.21.

What is the version I need to use?

Ofir

Hi Ofir,

Since you are using some older version of the product, so, the API might not be included, kindly try the latest version 4.5. I have also atttached the latest fix (4.5.0.28) for your need, kindly use it.

Thank you.