How to Add Image to Excel Comment Using userPicture Function?

Posted by: quangkm44 on 22 November 2025, 7:12 am EST

    • Post Options:
    • Link

    Posted 22 November 2025, 7:12 am EST

    Hello,

    I’m trying to add an image to a comment in an Excel file programmatically. I’m using the following function:

    [code]private static void addImageToCellComment(IRange cell, InputStream imageInputStream) throws IOException {

    if (imageInputStream == null || imageInputStream.available() == 0) {

    return;

    }

        // Optionally add a comment to indicate there's an image
        IComment comment = cell.addComment("Picture");
        comment.getShape().getFill().userPicture(imageInputStream, ImageType.PNG);
        comment.getShape().setWidth(200);
        comment.getShape().setHeight(200);
    }[/code]
    

    However, the image does not appear in the comment, and there are no error messages. I would appreciate any guidance or examples for getting this to work.

    I’m working on the version 8.1.1

  • Posted 24 November 2025, 12:22 am EST

    Hi Nguyễn,

    Apologies for the inconvenience caused.

    We can replicate the behavior you mentioned on our end. We are discussing this matter with the concerned team and will get back to you as soon as we receive any updates from their end.

    Internal Tracking ID: DOCXLS-13382

    Kind Regards,

    Chirag

  • Posted 5 December 2025, 12:03 am EST

    Hi Nguyễn,

    Thanks for your patience.

    The issue has been resolved in DsExcel v8.2.5.

    The attached sample application demonstrates that pictures in comments now work as expected.

    If you run into any other issues or need further help, feel free to reach out.

    Kind Regards,

    Chirag

    Attachment: commentimage.zip

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels