hi,
XLUtils does not include the possibility of using the setbackgroundimage method to insert a picture in the excel cell comments.
Is there anyone who can help me?
Thank you.
stackoverflow.com
XLUtils does not include the possibility of using the setbackgroundimage method to insert a picture in the excel cell comments.
Is there anyone who can help me?
Thank you.

apache poi insert comment with picture
I have an application where I am editing an excel xls file. I would like a snippet of code to demonstrate how to add a comment containing a png image. I already found sample code showing how to add a
B4X:
Private Sub AddComment (sheet As XLSheetWriter, address As XLAddress, CommentText As String,w As Int,y As Int)
Dim factory As JavaObject = sheet.Workbook.jWorkbook.RunMethod("getCreationHelper", Null)
Dim cell As PoiCell = sheet.GetCell(address)
Dim anchor As JavaObject = factory.RunMethod("createClientAnchor", Null)
anchor.RunMethod("setCol1", Array(address.Col0Based + 1))
anchor.RunMethod("setCol2", Array(address.Col0Based + 7))
anchor.RunMethod("setRow1", Array(address.Row0Based + 1))
anchor.RunMethod("setRow2", Array(address.Row0Based + 12))
anchor.RunMethod("setDx1", Array(w))
anchor.RunMethod("setDx2", Array(w))
anchor.RunMethod("setDy1", Array(y))
anchor.RunMethod("setDy2", Array(y))
Dim drawing As JavaObject = sheet.PoiSheet.As(JavaObject).RunMethod("createDrawingPatriarch", Null)
Dim comment As JavaObject = drawing.RunMethod("createCellComment", Array(anchor))
'Dim pcidx As Int = sheet.Workbook.jWorkbook.RunMethod("addPicture",Array(by,sheet.workbook.xl))
'comment.RunMethod("setBackgroundImage",Array(pcidx))
comment.RunMethod("setString", Array(factory.RunMethod("createRichTextString", Array(CommentText))))
'rowvalues(rowvalues.Length-2),rowvalues(rowvalues.Length-1)
cell.As(JavaObject).RunMethod("setCellComment", Array(comment))
Dim pcidx As Int = sheet.Workbook.PoiWorkbook.AddImage(File.DirTemp,CommentText)
comment.RunMethod("setBackgroundImage",Array(pcidx))
End Sub
Last edited: