Document Solutions for Excel, Java Edition | Document Solutions
Features / Shapes And Pictures / Image Transparency
In This Topic
    Image Transparency
    In This Topic

    DsExcel supports controlling the transparency of an image by providing setTransparency method in IPictureFormat interface. The value of transparency can vary between 0.0 (opaque) to 1.0 (clear).

    Using Code

    Refer to the following example code to set the transparency of an image.

    Java
    Copy Code
    // Create a new workbook
    Workbook workbook = new Workbook();
    
    // Use sheet index to get worksheet.
    IWorksheet worksheet = workbook.getWorksheets().get(0);
    
    // Add a picture
    IShape picture = worksheet.getShapes().addPicture("Image.png", 10, 10, 200, 100);
    
    // Set picture's transparency as 60%.
    picture.getPictureFormat().setTransparency(0.6);
    
    // Save to an excel file
    workbook.save("ImageTransparency.xlsx");


    Limitation

    SpreadJS does not support image transparency, hence this info would be lost when using json I/O.