You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by zzzimon <si...@hotmail.com> on 2014/01/30 10:48:27 UTC

Modifying /ppt/presentation.xml part, but nothing happens

Hi, I need to modify the /ppt/presentation.xml part but when I do that using
the part.getOutputStream method nothing happens. Here is my code:

	public static void main(final String[] args) throws Exception {
		final XMLSlideShow ppt = new XMLSlideShow();

		final PackagePart part = ppt.getPackage().getPart(
				PackagingURIHelper.createPartName("/ppt/presentation.xml"));

		final String content = "<HelloWorld />";

		final OutputStream os = part.getOutputStream();
		final PrintStream printStream = new PrintStream(os);
		printStream.print(content);
		printStream.close();

		// print slide show to pptx file
		final FileOutputStream out = new FileOutputStream("C:/simon/test.pptx");

		ppt.write(out);
		out.close();
	}

What I want the code to do is replace the content with the element
<HelloWorld />. But instead it still has its default content:
<p:presentation ...

What could be wrong?

/kind regards, Simon



--
View this message in context: http://apache-poi.1045710.n5.nabble.com/Modifying-ppt-presentation-xml-part-but-nothing-happens-tp5714775.html
Sent from the POI - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: Modifying /ppt/presentation.xml part, but nothing happens

Posted by zzzimon <si...@hotmail.com>.
Hi , thanks for your reply but I'm not sure what you mean. Can you give an
example?

/kind regards Simon



--
View this message in context: http://apache-poi.1045710.n5.nabble.com/Modifying-ppt-presentation-xml-part-but-nothing-happens-tp5714775p5714836.html
Sent from the POI - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: Modifying /ppt/presentation.xml part, but nothing happens

Posted by Nick Burch <ap...@gagravarr.org>.
On Thu, 30 Jan 2014, zzzimon wrote:
> Hi, I need to modify the /ppt/presentation.xml part but when I do that using
> the part.getOutputStream method nothing happens. Here is my code:
>
> 	public static void main(final String[] args) throws Exception {
> 		final XMLSlideShow ppt = new XMLSlideShow();

This creates a new in-memory /ppt/presentation.xml

> 		final PackagePart part = ppt.getPackage().getPart(
> 				PackagingURIHelper.createPartName("/ppt/presentation.xml"));
> 		final String content = "<HelloWorld />";
> 		final OutputStream os = part.getOutputStream();
> 		final PrintStream printStream = new PrintStream(os);
> 		printStream.print(content);
> 		printStream.close();

This updates the copy in the part, but...

> 		// print slide show to pptx file
> 		final FileOutputStream out = new FileOutputStream("C:/simon/test.pptx");
>
> 		ppt.write(out);

This then overwrites the /ppt/presentation.xml in the package with the one 
from the XMLSlideShow

You either need to work with the XMLSlideShow itself to edit the file, or 
only open at the OPCPackage level and not XSLF to have full control 
yourself

Nick

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org