0

This is my first ask on SO. Sorry if this has been answered in another question, but I haven't been able to find exactly what I need.

I'm have to use Apache POI 3.17 to generate a .xls report with some attached files (.doc and .ppt). Looking in other threads I have managed to generate the file without problems and add the attached files, but I would like to show its content into a frame instead as an object with an icon. Here is what i have:

POIFSFileSystem fs = new POIFSFileSystem(document.getDocument().getBinaryStream());
HSSFSheet tempSheet = workbook.createSheet(selectSheetName(usedNames, document.getDocumentName()));
int storageId = workbook.addOlePackage(fs, document.getDocumentName(), document.getDocumentName(), document.getDocumentName());
int picId = workbook.addPicture(getSamplePng(), HSSFPicture.PICTURE_TYPE_PNG);

HSSFPatriarch pat = tempSheet.createDrawingPatriarch();
HSSFClientAnchor anchor = pat.createAnchor(0, 0, 0, 0, 1, 2, 2, 6);
HSSFObjectData od = pat.createObjectData(anchor, storageId, picId);
od.setNoFill(true);

With that I create an icon that opens a word or PowerPoint when the user clicks it. And I want some like what you obtain when you use Insert->Object->Create From File Menu

http://oi65.tinypic.com/2vd065g.jpg

  • hi, I guess this shall help you: http://poi.apache.org/components/spreadsheet/quick-guide.html#Embedded – robot_alien Jul 30 '18 at 13:58
  • Thank you, but the official documentation is quite scarce. In the link that you send me only appears information on how to get the existing embbed objects of a file to work with them, but nothing of how to create them or how to make them show it's content. – Ricardo Martinez Jul 31 '18 at 07:36
  • 1
    Now that I have gotcha right, you are talking about OLE using apache-poi, see: https://stackoverflow.com/a/16879830/1004631 here the author @kiwiwings has stated an example taking into consideration powerpoint, you can check that! – robot_alien Jul 31 '18 at 09:57

0 Answers0