Insert Image Hyperlinks in Excel in Java

This article demonstrates how to insert an image into Excel and add a hyperlink to it using Spire.XLS for Java.

import com.spire.xls.*;

public class InsertImageHyperlink {

    public static void main(String[] args) {

        //Create a Workbook instance and get the first worksheet
        Workbook wb = new Workbook();
        Worksheet sheet = wb.getWorksheets().get(0);

        //Insert text in the cell A1
        sheet.getCellRange("A1").setText("Image Hyperlink");

        //Insert an image to the cell A1
        String picPath = "C:\\Users\\Administrator\\Desktop\\logo.png";
        ExcelPicture picture = sheet.getPictures().add(1,1,picPath);

        //Set a hyperlink for the image
        picture.setHyperLink("Http://", true);

        //Set the column width and row height

        //Save the document
        wb.saveToFile("ImageHyperlink.xlsx", ExcelVersion.Version2016);

Insert Image Hyperlinks in Excel in Java