We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Aspose Java - Embeding Excel OLE object to PPT


I am using Aspose Slide java aspose.slides-7.2.0 and aspose-cells-7.4.2 for Embeding Excel OLE object to PPT using below code, not sure what is wrong, I am getting below error. I am attaching the excel which I am using .


error: cannot find symbol
int width =(int) pres.getSlideSize().getX() - 1000;
symbol: method getX()
location: class SlideSizeEx
error: cannot find symbol
int height =(int) pres.getSlideSize().getY();
symbol: method getY()
location: class SlideSizeEx
2 errors

import com.aspose.slides.;
import com.aspose.cells.;
import com.aspose.metafiles.;

import java.io.Serializable;

import java.io.;
import java.util.;

import java.text.SimpleDateFormat;

import java.lang.reflect.;

public class testPPT
public static void main(String[] args)
//Instantiate PrseetationEx class that represents the PPTX
PresentationEx pres = new PresentationEx();

//Access the first slide
SlideEx sld = pres.getSlides().get_Item(0);

//Load an Excel file to Array of Bytes
File file=new File(“C:\Test_Report\UAT\Sample.xls”);
int length=(int)file.length();
FileInputStream fstro = new FileInputStream(file);
byte[] buf = new byte[length];
fstro.read(buf, 0, length);
int xPos = 1000 / 2;
int yPos = 0;
int width =(int) pres.getSlideSize().getX() - 1000;
int height =(int) pres.getSlideSize().getY();
//Add an Ole Object Frame shape
OleObjectFrameEx oof = sld.getShapes().addOleObjectFrame(xPos, yPos, width, height, “Excel.Sheet.8”, buf);
//Write the PPTX to disk
// pres.write(“C:\Test_Report\UAT\hello.ppt”);
} catch (Exception e) {

Hi Mohan,

Please replace the problematic lines with following statements in your code and hopefully things will work.

int width =(int) (pres.getSlideSize().getSize().getWidth() - 1000);
int height =(int) pres.getSlideSize().getSize().getHeight();

Many Thanks,

Hi Fayyaz,

Thanks you for immediate response. I tried the solution which you provided, error is resolved. When I try to open the ppt file , I see Object Changed message and when I double click the Object change message excel image opens up, is there any option we need to set so that when we open the ppt the data is displayed and excel template is removed. I am attaching both screen shots for refernce, please let me know if you need more details.



Hi Mohan,

I like to share that the issue shared is in fact not an issue. Actually, when the Ole frame is added, it is in de-active state by default. The “Ole embed message” is actually set be Ole Engine as default image. Please visit this documentation link for your kind reference. There are some third party solutions available that you may try to explore on your end. Please visit this documentation link for your kind reference. Aspose.Cells is capable of generating the sheet or chart image. You can extract that image and set that Ole frame image. For your convenience, please visit this documentation link and observe the sample code where the chart image is taken.

Many Thanks,