Comment formatting

3 questions,

A. How to add rich text to comments?

B. How to make a perticular cell invisible? I can't see any property exposed with the cell api?

C. On sheet, there is a column which can have string value or an integer value. I am adding data using putvalue method of the cell api. However cell is automatically adding "Number Stored As Text" message to all the cells where it finds a number. I've already converted the data to string type before adding it to the cell. What else needs to be done to resolve the datatype on the cell.

Do I need to do a type check all the time before adding data and used appropriate "StringValue", or "BooleanValue" etc methods?

Hi,

dvd.vinay:

A. How to add rich text to comments?

Please see the following sample code for your reference:

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("e:\\test\\formattedcomments_chars.xls");

dvd.vinay:

B. How to make a perticular cell invisible? I can't see any property exposed with the cell api?

Well, you need to hide the relative row/column of the cell. For reference, please see the document:

http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/hidingunhiding-rows-and-columns.html


dvd.vinay:

C. On sheet, there is a column which can have string value or an integer value. I am adding data using putvalue method of the cell api. However cell is automatically adding "Number Stored As Text" message to all the cells where it finds a number. I've already converted the data to string type before adding it to the cell. What else needs to be done to resolve the datatype on the cell.

Do I need to do a type check all the time before adding data and used appropriate "StringValue", or "BooleanValue" etc methods?



Yes, MS Excel will show this message when you have inserted numbers as string. I think you may try to use an overloaded version of Cell.PutValue method, e.g
cell.PutValue(stringval, true); //Please specify true for the second parameter (bool isConverted).

Thank you.

1. I am adding comments dynamically and it will be very difficult to follow this approach. Is there any way I can put any tags to format the code. The way, we can do in HTML?

2. When I am using bool isConverted = true, integer value 12345 is geting converted to 12345.0000. I suppose this will happen to other data types as well; e.g Date. Is there any ways to over ride this behaviour?

Hi,

2) You will only use the approach for the strings (numbers stored as text) in the way as mentioned in the following line of code.

cell.PutValue(“123”, true);

now, the cell would have numeric data and you don’t get the message (“Numbers stored as text”) in MS Excel.


Thank you.

True but, the ".0000" is getting appended to my numbers now. I don't want this to happen. For example; when the value is 123456 the cell is displaying 123456.0000. Is there any method to over ride this behaviour using the code snippet given above?

And what about point number 1 regarding dynamic rich text to comments?

Ah, the cell is formatted to have 4 decimal places. So, I suppose; I will have to override this behaviour through code.

Can you please provide me any snipped to achieve Rich text for cell comments dynamically using any tag based approach (similar to Cell.HtmlString)? End user would like to check the comment text based on requirements.

Hi,

1) Currently we only support to parse the following Html attributes/tags:
, ,,,,,, and


So, you have to use my mentioned approach to richly formatted comment text accordingly. Also, you can make use the following attributes for Comment class to format data:
Font, TextHorizontalAlignment, TextOrientationType, TextVerticalAlignment etc.

Thank you.

No Amjad,

Rich formatting on comments in not working using HTML tags. Let me know, if I am missing something here.

Following is the code

int index1 = localSheet.Comments.Add(column.CurrentCellLocation);

Comment c1 = localSheet.Comments[index1];

c1.Note = "Hello";

Check the file attachment for output. My aspose version is 4.8.2.9.

Thanks

Hi,

Well, I am afraid, the tags/attributes which I shared are supported in Cell.HtmlString/PutValue API only. So, you cannot insert html tags in a Comment’s note.

you may just use:
c1.Note: “Hello”;
c1.Font.IsBold = true;


Thanks for your understanding!

Can you please add this feature into this product?

Also, can you also provide me the link where we can request for the licence?

Hi,

dvd.vinay:

Can you please add this feature into this product?

We have added your feature request into our issue tracking system with an issue id: CELLSNET-15406. We will inform you when it supported.

dvd.vinay:

Also, can you also provide me the link where we can request for the licence?



Please contact Aspose.Purchase team:
http://www.aspose.com/community/forums/aspose.purchase/220/showforum.aspx


Thank you.




Hi,

Please try the attached version.

We have supported getting and setting the html string note with Comment.HtmlNote property.

Thank you.

Sure, let me try this. Thanks for your help.