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

Free Support Forum - aspose.com

Comment cell with picture

Does the java component have support to create comment cell with picture? I saw such support in the .NET examples but not in the Java.

Hi,


Yes, it is supported.

See the sample code:

Sample code:

//Instantiate a Workbook
Workbook workbook = new Workbook();
//Get a reference of comments collection with the first sheet
CommentCollection comments = workbook.getWorksheets().get(0).getComments();
//Add a comment to cell A1
int commentIndex = comments.add(0, 0);
Comment comment = comments.get(commentIndex);
comment.setNote(“First note.”);
comment.getFont().setName(“Times New Roman”);

//Load an image into stream
String logo_url = “e:\test\school.jpg”;
//Creating the instance of the FileInputStream object to open the logo/picture in the stream
FileInputStream inFile = new FileInputStream(logo_url);
//Setting the logo/picture
byte[] picData = new byte[inFile.available()];
inFile.read(picData);

//Set image data to the shape associated with the comment
comment.getCommentShape().getFillFormat().setImageData(picData);
//Save the workbook
workbook.save(“commentwithpicture1.xlsx”);

I will soon add an article to the Java documentation accordingly.

Thank you.