Updating Excel OLE object data in presentation failed OLE frame to open in PowerPoint (Java)

I have a Presentation (aspose.slides) with an embedded Excel file, that ends with “.bin”. I want to open this file, but the format seems to be not supported. My problem sounds like this one, but I wanted to be sure that it’s still not possible.

@fbu,
Thank you for your query. Please share your template file along with the runnable console application to reproduce this issue here.

@ahsaniqbalsidiqui,

Thank you for your reply.

I have an update on this matter: We can open the embedded excel files as Workbook object instances with the current version of aspose.cells. We can make changes on the Workbook instance and save it back to the OleObjectFrame instance.

However, when we open the presentation (pptx file) afterwards with PowerPoint, the embedded excel can’t be opened. I played a bit with the SaveFormat but without luck. The template contains three Excel files - one on each slide at the bottom. Please try to “open” them with a double click from within PowerPoint. You’ll get an exception.

files.zip (762.5 KB)

This is the code snippet:

  Presentation presentation = new Presentation(FILE_NAME);
  StreamSupport.stream(presentation.getSlides().spliterator(), false)//
          //every slide
          .forEach(slide -> StreamSupport.stream(slide.getShapes().spliterator(), false)//
                  //every shape
                  .filter(shape -> shape instanceof OleObjectFrame)//
                  //every OleObjectFrame
                  .filter(oleObjectFrame -> ((OleObjectFrame) oleObjectFrame).getEmbeddedFileName().endsWith(".bin") //
                          || ((OleObjectFrame) oleObjectFrame).getEmbeddedFileName().endsWith(".xlsx"))//
                  //every embedded excel
                  .forEach(excel -> {
                    byte[] objectData = ((OleObjectFrame) excel).getObjectData();
                    ByteArrayInputStream is = new ByteArrayInputStream(objectData);
                    try {
                      //determine format
                      FileFormatInfo fileFormat = FileFormatUtil.detectFileFormat(is);
                      int fileFormatType = fileFormat.getFileFormatType();
                      
                      //open workbook
                      Workbook workbook = new Workbook(is); //NoClassDefFoundError for 
                      ByteArrayOutputStream os = new ByteArrayOutputStream();
                      
                      //save the data back to the frame
                      workbook.save(os, fileFormatType);
                      ((OleObjectFrame) excel).setObjectData(os.toByteArray());
                    } catch (Exception e) {
                      sysLogger.error("error at opening workbook", e);
                    }
                  }));
  presentation.save(OUTPUT_NAME, SaveFormat.Pptx);

@fbu,

I have worked with source file and provided sample code. It seems to be an issue with Aspose.Slides. An issue with ID SLIDESJAVA-38058 has been created in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.

The issues you have found earlier (filed as SLIDESJAVA-38058) have been fixed in this update.