hi, i think it should be simple but i cannot find the method.
after adding a new note into cell… the background color of the note is ‘white’.
However, in excel, the background color of the note is yellow.
How can I set the background color of the note same as the excel background color?
Example code as following…
var sourceSheet = _workbook.Worksheets[sheetName];
var commentIndex = sourceSheet.Comments.Add(cellAddress);
var comment = sourceSheet.Comments[commentIndex];
comment.Note = note;
@catalparue26,
Thanks for the code segment and details.
See the following sample code on how to set comment/note formatting/color (especially second comment) for your reference, you may change the code accordingly:
e.g
Sample code:
//Instantiate the Workbook
Workbook workbook = new Workbook();
//Get a reference of comments collection with the first sheet
CommentCollection comments = workbook.Worksheets[0].Comments;
//Add a comment to cell A1
int commentIndex = comments.Add(0, 0);
Comment comment = comments[commentIndex];
comment.Note = "First note.";
comment.Font.Name = "Times New Roman";
//Load an image into stream
Bitmap bmp = new Bitmap("e:\\test\\school.jpg");
MemoryStream ms = new MemoryStream();
bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
//Set image data to the shape associated with the comment
comment.CommentShape.FillFormat.ImageData = ms.ToArray();
commentIndex = comments.Add(2, 1);
Comment comment2 = comments[commentIndex];
comment2.Note = "Second note.";
LineFormat lineFormat = comment2.CommentShape.Line;
lineFormat.SolidFill.Color = Color.Red;
FillFormat fillFormat = comment2.CommentShape.Fill;
fillFormat.SolidFill.Color = Color.Pink;//you may change the color
//Save the workbook
workbook.Save("e:\\test2\\out2_comments_formatting.xlsx");
Hope, this helps a bit.
great! thanks! this help.