Hi,
The default background in a new comment isn’t transparent. If you try with:
XlsFile xls = new XlsFile(1, true);
xls.SetComment(1, 1, "Hello");
xls.Save("r:\test.xlsx");
You’ll get a yellow background.
The transparent background happens if you do:
xls.SetComment(1, 1, "Hello", "", new TCommentProperties(new TClientAnchor(TFlxAnchorType.MoveAndDontResize, 2, 0, 2, 0, 5, 0, 5, 0), ""));
But that’s because the line new TCommentProperties(…) is generating empty comment properties, and this means a transparent background. If you want to set the properties, you should call:
xls.SetComment(1, 1, "Hello", "", TCommentProperties.CreateStandard(1, 1, xls));
This will create a comment with a yellow background.
Now, about how to change the color, you could use some code like this:
XlsFile xls = new XlsFile(1, true);
string CommentText = "this is a comment with a light blue background";
var CommentProperties = TCommentProperties.CreateStandard(2, 7, xls);
CommentProperties.ShapeFill = new TShapeFill(true, new TSolidFill(Colors.LightBlue));
xls.SetComment(2, 7, CommentText, "", CommentProperties);
xls.Save("r:\test.xlsx");
Note that you can also autofit the comment to the text with a line like this:
CommentProperties.Anchor = xls.AutofitComment(new TRichString(CommentText, null, xls), 1.5, true, 1.1, 0, CommentProps.Anchor);
before setting the comment.