B4J Question XLUTILS - Request for insert an image to excel cell comment

moore_it

Well-Known Member
Licensed User
Longtime User
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.


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

1758187014139.png
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0
Top