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

Free Support Forum - aspose.com

java.lang.NullPointerException is thrown by getOleFormat

I use above code but it throw the NULL Pointer Exception
Exception in thread “main” java.lang.NullPointerException
at com.sps.test.EmbbedImage.main(EmbbedImage.java:20)"

Line no 20: if(oleFormat.getProgId() == “Excel.Sheet.12”)


Please ZIP and attach your input and expected output documents here for testing. We will investigate the issue and provide you more information on it.

1 Like


Desktop.zip (124.3 KB)


Your input document does not contain the embedded object. Please open your document in MS Word and right click on it to edit it. You will notice that it is not OLE object.

You can check either Shape.OleFormat property returns null or not as shown below to avoid the shared exception.

OleFormat oleFormat = shape.getOleFormat();
if(oleFormat != null && oleFormat.getProgId() == "Excel.Sheet.12")
    //Your code...