// Create a new workbook Workbook workbook = new Workbook(); IWorksheet worksheet = workbook.getWorksheets().get(0); InputStream stream = this.getResourceStream("Chrome_icon.png"); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); byte[] buffer = new byte[4096]; int bytesRead; while (true) { try { if (!((bytesRead = stream.read(buffer)) != -1)) break; } catch (IOException e) { throw new RuntimeException(e); } outputStream.write(buffer, 0, bytesRead); } byte[] imagebyte = outputStream.toByteArray(); worksheet.getRange("A2:E2").setValue(new String[] { "Stretch", "Center", "Zoom", "None", "Default(Stretch)" }); worksheet.getRange("A3:E3").setValue("Chrome"); worksheet.getRange("A3:E3").setRowHeightInPixel(80); worksheet.getRange("A3:E3").setColumnWidthInPixel(100); //Add cell background picture worksheet.getRange("A3:E3").setBackgroundImage(imagebyte); //Set image layout worksheet.getRange("A3").setBackgroundImageLayout(BackgroundImageLayout.Stretch); worksheet.getRange("B3").setBackgroundImageLayout(BackgroundImageLayout.Center); worksheet.getRange("C3").setBackgroundImageLayout(BackgroundImageLayout.Zoom); worksheet.getRange("D3").setBackgroundImageLayout(BackgroundImageLayout.None); //Set options workbook.getActiveSheet().getPageSetup().setPrintGridlines(true); workbook.getActiveSheet().getPageSetup().setPrintHeadings(true); // Save to a pdf file workbook.save("CellBackgroundImage.pdf");