Bug 61797 - Embed Excel / Ole objects into powerpoint
Summary: Embed Excel / Ole objects into powerpoint
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: SL Common (show other bugs)
Version: 4.0.x-dev
Hardware: All All
: P2 enhancement (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-11-21 23:43 UTC by Andreas Beeker
Modified: 2018-06-17 22:05 UTC (History)
1 user (show)



Attachments
Initial patch (15.53 KB, application/gzip)
2017-11-21 23:43 UTC, Andreas Beeker
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Beeker 2017-11-21 23:43:14 UTC
Created attachment 35543 [details]
Initial patch

There's been some work done to embed Excel into Powerpoint slides (HSLF) [1], but the XSLF part is missing.

This ticket is used to document the progress - eventually provide the implementation via SL Common.

The patch shows how to embed XSSF into XSLF.
Additionally it provides a filename generation method to check for existing media/embedding entries and to create new entries, potentially filling up already deleted indexes.

The work is done as response to [2]


[1] #55579 and https://stackoverflow.com/questions/2849102
[2] https://stackoverflow.com/questions/46987387
Comment 1 Andreas Beeker 2017-12-31 01:17:24 UTC
applied via r1819710
Comment 2 Kem 2018-06-17 05:12:40 UTC
I have tried adding an excel(.xslx) spreadsheet to a powerpoint(.pptx). But so far I havent been unable to do it. I tried recreating the class that you created[EmbedXSSFinXSLF.java] but the line that retrieves the ObjectData from the oleShape[ XSLFObjectData oleData = oleShape.getObjectData();] is throwing a null pointer exception.

below is the error:
Exception in thread "main" java.lang.NullPointerException
	at org.apache.poi.xslf.usermodel.XSLFObjectShape.getObjectData(XSLFObjectShape.java:109)
	at poi.Main.main(Main.java:58)

I guess my question would be, is there currently a way to embed a excel spreadsheet(.xslx) into a powerpoint(.pptx)? if not, is there a way to do it using the old .ppt and .xsl formats?

(In reply to Andreas Beeker from comment #0)
> Created attachment 35543 [details]
> Initial patch
> 
> There's been some work done to embed Excel into Powerpoint slides (HSLF)
> [1], but the XSLF part is missing.
> 
> This ticket is used to document the progress - eventually provide the
> implementation via SL Common.
> 
> The patch shows how to embed XSSF into XSLF.
> Additionally it provides a filename generation method to check for existing
> media/embedding entries and to create new entries, potentially filling up
> already deleted indexes.
> 
> The work is done as response to [2]
> 
> 
> [1] #55579 and https://stackoverflow.com/questions/2849102
> [2] https://stackoverflow.com/questions/46987387
Comment 3 PJ Fanning 2018-06-17 08:55:19 UTC
Which poi version did you use? Did you build the latest poi code from into your own jars - Andreas' change has not been released yet but will appear in v4.0.0 when it is released.

https://github.com/plutext/docx4j/blob/master/src/samples/pptx4j/org/pptx4j/samples/EditEmbeddedCharts.java is a sample that might be worth looking at (uses the docx4j libs as opposed to poi libs)
Comment 4 Kem 2018-06-17 12:59:28 UTC
Hi, PJ Fanning

Thanks for the reply. I did use the Andreas' latest snapshot of the code. I compiled it from Andreas mirror poi project in github, which include the classes that were necessary to build the EmbedXSSFinXSLF.java.

I have never used docx4j before, ill look into it. Hopefully it gives me an idea on how to do it on poi or at least use docx4j to insert the excel table into the powerpoint slide.

Thanks for the help.
Comment 5 Andreas Beeker 2018-06-17 17:22:41 UTC
Hi Kem,

the embedding test class is at [1], but first of all, when you talk about embedding, do you simply want to attach any file in form of a packager object to the slide (then I open the ticket again and see if I can fix the problem) or do you want to show the contents of the Excel (then I'd ask you about opening a new bugzilla entry)?

Andi


[1] https://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/sl/TestOleShape.java?view=markup
Comment 6 Kem 2018-06-17 22:05:08 UTC
Hi, Andi

Thanks for the help, it worked. It seems that Office 2007 doesn't know how to properly handle the outputted file by Office 2016 does seem to know. I also tried the latest version of LibreOffice and it also works there. I added the code [1] the I used to my Git-Hub repository in case someone is looking to do the same thing that I wanted to do.

Again thanks for all you help.


[1]
https://github.com/Rasgris/TestPoi/blob/master/EmbedXSSFintoXSLF