This short tutorial describes how to embed Excel in PowerPoint using Java. It has the details to set the development environment, a list of steps defining the process, and a sample code that you may use to embed Excel file in PowerPoint using Java. It will also describe the option to display the Excel file icon on the slide.
Steps to Embed an Excel File in PowerPoint using Java
- Establish the environment to use Aspose.Slides for Java for embedding the Excel file
- Create or load a Presentation for inserting Excel into it
- Get the reference of the target slide in the ISlide class object
- Use the Files.readAllBytes() method to read the source Excel file
- Instantiate the OleEmbeddedDataInfo object using the bytes array
- Invoke the addOleObjectFrame method to add a frame with data info
- Set the flag to show the object icon in the slide and save the presentation
These steps explain how do you embed an Excel file in PowerPoint using Java. Create the Presentation class object and access its first slide followed by reading the source Excel file into the byte array. Create the OleEmbeddedDataInfo object with this byte array and add the OLE object in the slide using the addOleObjectFrame() method.
Code to Insert Excel Workbook into PowerPoint using Java
The above-mentioned sample code demonstrates how to embed Excel workbook in PowerPoint using Java. You may either display an icon for the embedded Excel file or display the file contents directly by setting the flag in the setObjectIcon() method. All types of files can be embedded using the same technique described in this article.
This article has taught us the integration of an Excel file in the presentation. To add an audio file to a presentation, refer to the article on How to add audio in presentation using Java.