Well, for work I've been writing code to make these certificates of calibration straight from the database files in which we store the test data, and I've been using the Apache POI to do this. I've gotten pretty far, and I've been moving along fairly quickly once I figured things out. However, I ran into this issue early on and skipped it, hoping I could find a fix for it once I was done with the rest of it. The issue is thus: the example code provided to insert an image doesn't work. The sample code can be viewed here. When I compile all my code, the snippet below yields two errors:
1) The method createDrawingPatriarch() is undefined for the type Sheet
2) The method createClientAnchor() is undefined for the type CreationHelper
Which is an obvious lie, because I scoured through the Javadocs and found the methods right where they're supposed to be. Does anyone know why this is happening, and if so how do I fix it?
Code: Select all
//Add the logo image:
//Add picture data to the workbook
InputStream logo = new FileInputStream("Logo.jpeg");
byte[] bytes = IOUtils.toByteArray(logo);
int logoIdx = wb.addPicture(bytes, Workbook.PICTURE_TYPE_JPEG);
logo.close();
CreationHelper helper = wb.getCreationHelper();
//Create drawing "patriarch" the top level container for all shapes
HSSFPatriarch logoPat = sheet.createDrawingPatriarch(); //error 1
//Add a picture shape
HSSFClientAnchor logoAnchor = helper.createClientAnchor(); //error 2
//Set top-left corner of the picture, all calls of resize() will operate relative to this corner
logoAnchor.setCol1((short)0);
logoAnchor.setRow1(1);
HSSFPicture logoImg = logoPat.createPicture(logoAnchor, logoIdx);
I tried to comment things as well as possible. edit: I suppose I should fend off the "JFGI" comments with: I've spent about 2 hours wandering around google results trying different things; nothing has worked.