Hello,
I am trying to insert an excel sheet as an embedded OLE object into a new presentation. The powerpoint file is created but I don’t see the excel sheet in the slide (See attached files).
I am evaluating aspose.slides-15.5.1-jdk16.jar
I have used the following code:
//Instantiate Prseetation class that represents the PPTX
Presentation pres = new Presentation();
//Access the first slide
ISlide sld = pres.getSlides().get_Item(0);
//Load an Excel file to Array of Bytes
File file = new File(“testOle.xlsx”);
int length = (int) file.length();
FileInputStream fstro = new FileInputStream(file);
byte[] buf = new byte[length];
fstro.read(buf, 0, length);
//Add an Ole Object Frame shape
IOleObjectFrame oof = sld.getShapes().addOleObjectFrame((float)0,(float) 0, (float)pres.getSlideSize().getSize().getWidth(),(float) pres.getSlideSize().getSize().getHeight (), “Excel.Sheet.8”, buf);
//Write the PPTX to disk
pres.save(“testOle.pptx”, SaveFormat.Pptx);
Thanks and regards,
Rafic
Hi Rafic,
I have observed the issue shared by you. You are actually embedding and XLSX file as Ole frame in presentation, where as you are using “Excel.Sheet.8” as class name on setting ole frame. This class name is valid if you are using XLS file. You need to use “Excel.Sheet.12” as class name for XLSX format. Please try using following modification in your sample code to serve the purpose.
IOleObjectFrame oof = sld.getShapes().addOleObjectFrame((float)0,(float) 0, (float)pres.getSlideSize().getSize().getWidth(),(float) pres.getSlideSize().getSize().getHeight (), “Excel.Sheet.12”, buf);
Please share, if I may help you further in this regard.
Many Thanks,