You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Christian Märzinger <ch...@gmail.com> on 2011/01/07 22:55:20 UTC
Load a XML file into a part
Hello!
I tried to load a DOM-XML file into a part but became the following error.
org.apache.poi.openxml4j.exceptions.InvalidFormatException: Method not
implemented
at
org.apache.poi.openxml4j.opc.internal.MemoryPackagePart.load(MemoryPackagePart.java:114)
so is there another possibility to load or write into a part?
Thanks
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org
Re: Load a XML file into a part
Posted by Nick Burch <ni...@alfresco.com>.
On Mon, 10 Jan 2011, Christian Märzinger wrote:
> But therefore I have to implement my on PackagePart only for the use of
> save();
>
> I's there the possibility that save(OutputStream) can handle a
> MemoryPackageOutputStream to not only ZipOutputStream?
> OPCPackage returns a ZipPackagePart and this ZipPackagePart returns the
> MemoryPackageOutputStream by the method getOutputstream();
I'm afraid I have absolutely no idea what you're asking...
The PackagePart can give you an OutputStream, and you write your XML
content into that. You then save the overall OPCPackage, and the new
content will be in it. Is that what you're doing? If so, at what point is
it failing? (A failing unit test may be a good bet too, as it'll show
exactly what code you're calling)
Nick
Re: Load a XML file into a part
Posted by Christian Märzinger <ch...@gmail.com>.
But therefore I have to implement my on PackagePart only for the use of
save();
I's there the possibility that save(OutputStream) can handle a
MemoryPackageOutputStream to not only ZipOutputStream?
OPCPackage returns a ZipPackagePart and this ZipPackagePart returns the
MemoryPackageOutputStream by the method getOutputstream();
Am 10.01.2011 13:01, schrieb Nick Burch:
> On Mon, 10 Jan 2011, Christian Märzinger wrote:
>> I' am looking in the poi source under
>>
>> http://svn.apache.org/repos/asf/poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/CommentsTable.java
>>
>>
>> But I don't find there any helpful information.
>
> That's the place to look. It shows reading from the package part,
> processing the xml, serialising the xml and writing it back to a
> package part.
>
> Nick
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org
Re: Load a XML file into a part
Posted by Nick Burch <ni...@alfresco.com>.
On Mon, 10 Jan 2011, Christian Märzinger wrote:
> I' am looking in the poi source under
>
> http://svn.apache.org/repos/asf/poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/CommentsTable.java
>
> But I don't find there any helpful information.
That's the place to look. It shows reading from the package part,
processing the xml, serialising the xml and writing it back to a package
part.
Nick
Re: Load a XML file into a part
Posted by Christian Märzinger <ch...@gmail.com>.
Hello Nick!
I' am looking in the poi source under
http://svn.apache.org/repos/asf/poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/CommentsTable.java
But I don't find there any helpful information.
Could you please give me the link to the CommentsTable where you mean I
find the information
Am 08.01.2011 01:49, schrieb Nick Burch:
> On Sat, 8 Jan 2011, Christian Märzinger wrote:
>> Could you give my a hint, what I do wrong.
>>
>> OutputStream bais = new ByteArrayOutputStream();
>>
>> bais.write(strComment.getBytes(), 0,
>> strComment.getBytes().length);
>>
>> ZipOutputStream comentZipOutput= new ZipOutputStream(bais);
>>
>> comment.save(comentZipOutput);
>
> I've no idea what you're trying to do here, sorry, but it doesn't look
> anything like that code I'd expect to see...
>
> Try taking a look at the source of
> org.apache.poi.xssf.model.CommentsTable
> - it shows how to read the contents of a PackagePart, pass it off for
> xml processing, then get the xml back and into the PackagePart at the end
>
> Nick
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org
Re: Load a XML file into a part
Posted by Nick Burch <ni...@alfresco.com>.
On Sat, 8 Jan 2011, Christian Märzinger wrote:
> After I have read the OutputStream of the PackagePart how do I write my
> String into the part?
You can't read from an OutputStream...
You read the xml from the input stream, change it as required (quite
possibly using xmlbeans, but you don't have to), then write it out to the
output stream
Nick
Re: Load a XML file into a part
Posted by Christian Märzinger <ch...@gmail.com>.
After I have read the OutputStream of the PackagePart how do I write my
String into the part?
Am 07.01.2011 23:46, schrieb Nick Burch:
> On Fri, 7 Jan 2011, Christian Märzinger wrote:
>> so is there another possibility to load or write into a part?
>
> You'll probably want the getInputStream and getOutputStream methods on
> PackagePart - they let you read and write the contents of the part
>
> Nick
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org
Re: Load a XML file into a part
Posted by Nick Burch <ni...@alfresco.com>.
On Fri, 7 Jan 2011, Christian Märzinger wrote:
> so is there another possibility to load or write into a part?
You'll probably want the getInputStream and getOutputStream methods on
PackagePart - they let you read and write the contents of the part
Nick