We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Set Image as Background for Cell Comment in Excel 2007 file using Aspose.Cells for .NET in C#

Hi Guys,

With Excel 2007 it is possible to have an image as the background to a cell comment.

In Excel 2007 this is accomplished by doing the following :- Edit Comment, right click on the comment border, select Format Comment... then the Colorrs and Lines tab, drop down the color combo and select Fill Effects then the Picture tab to select an image.

How can this be done using Aspose.Cells (using C# Winforms)?



Thanks for the inquiry.

Following is a sample to create an XLSX from scratch and add some comments to cell “A1” with picture of the first sheet.

//Instantiate the Workbook
Workbook workbook = new Workbook();
//Get a reference of comments collection with the first sheet
CommentCollection comments = workbook.Worksheets[0].Comments;
//Add 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(“d:\asp.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();
//Save workbook

Kind Regards


Thanks for the code, I had already tried code almost identical to that and it does not work

I have attahced two files, the first is the output from your code (and I did have a d:\\asp.jpg) and the second is an excel2007 spreadhseet with an image in the comment using the methof I outlined.

Any thoughts?


We have tested the code with the attached latest version v5.1.1.3 and it works, we use sample image file for the comment’s background. Please try the attached version and let us know if it works fine now.

If you still find the issue, give us your sample image here. We will check it soon.

Thank you.


That works fine with, thanks for the quick response.