// Create a new workbook Workbook workbook = new Workbook(); // Open an excel file InputStream fileStream = this.getResourceStream("xlsx/To_Do_List.xlsx"); workbook.open(fileStream); IWorksheet worksheet = workbook.getWorksheets().get(0); // Set a background image for worksheet InputStream stream = this.getResourceStream("AcmeLogo.png"); // Add a background picture for the worksheet, and the background picture will be rendered into the destination rectangle[10, 10, 500, 370]. IBackgroundPicture picture = null; try { picture = worksheet.getBackgroundPictures().addPictureInPixel(stream, ImageType.PNG, 10, 10, 500, 370); } catch (IOException e) { // Log ignored error of your code // log.debug(e.getMessage()); } // The background picture will be resized to fill the destination dimensions. picture.setBackgroundImageLayout(ImageLayout.Tile); // Sets the transparency of the background pictures. picture.setTransparency(0.5); // Save to an pdf file workbook.save("SaveBackgroundPicturesToPDF.pdf");
// Create a new workbook var workbook = Workbook() // Open an excel file val fileStream = this.getResourceStream("xlsx/To_Do_List.xlsx") workbook.open(fileStream) val worksheet = workbook.getWorksheets().get(0) // Set a background image for worksheet val stream = this.getResourceStream("AcmeLogo.png") // Add a background picture for the worksheet, and the background picture will be rendered into the destination rectangle[10, 10, 500, 370]. try { val picture = worksheet.getBackgroundPictures().addPictureInPixel(stream, ImageType.PNG, 10.0, 10.0, 500.0, 370.0) // The background picture will be resized to fill the destination dimensions. picture.setBackgroundImageLayout(ImageLayout.Tile) // Sets the transparency of the background pictures. picture.setTransparency(0.5) } catch (e: IOException) { // TODO Auto-generated catch block e.printStackTrace() } // Save to an pdf file workbook.save("SaveBackgroundPicturesToPDF.pdf")