This content has been marked as final. Show 6 replies
> but I can't seem to figure the image part out. I am not calling the loadPicture correctly, which is confusing CF.
You did not mention which version of POI. Did you verify your version supports the patriarch.createPicture method? If you are using a really old version it might not.
> loadPicture("asset/images/logo_e2eA.png", workSheet))/>
Does the code actually have access to a loadPicture() method or function? I think loadPicture() is a private method in one of the example classes: org.apache.poi.hssf.usermodel.examples.*. So you may have to write your own version of it. Assuming you have not done so already...
I found the source code for the loadPicture method in svn and adapted it to CF. Here is a working example. It creates a new workbook, adds an image, and saves the file to disk.
A few notes about the code snippet. The code uses the JavaLoader.cfc
JavaLoader.cfc to load a newer version of the POI jar. The loadPicture function assumes the image is .png format. Adapt it as needed.
I tweaked the code and here is a simplified version. The same notes apply: it requires the JavaLoader.cfc and assumes the image is .png format.
Thanks for posting this - I've been struggling with this for a while. Can't wait to try it out.
I was hoping to utilize the POI that is deployed with CF 8. I noticed on your blog that the POI deployed with CF may be only a partial version of 2.5.1. This version does not seem to have addPicture method for HSSFWorkbook?
Thanks for posting an alternate solution.
> This version does not seem to have addPicture method for HSSFWorkbook?
You are welcome. Yes, it does not appear to contain some of the packages like HWPF (for Word documents). As far as HSSFWorkbook.addPicture goes, it is probably just a version issue. I think addPicture was introduced after version 2.5.1.