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/10 01:33:55 UTC
Error deleting Part
Hello!
I try do delete a part of a docx file.
first I grab the part with the following code
PackagePartName commentsPart = PackagingURIHelper.createPartName("/word/comments.xml")
comment = opcPackage.getPart(commentsPart);
then I try to delete it
opcPackage.delete(comment);
In debug the comment part is not null and also I find the part in the
partlist.
But I get the error
java.lang.IllegalArgumentException: partName
Do I have to delete the relationships manually or something other?
Thanks
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org
Re: Error deleting Part
Posted by Nick Burch <ni...@alfresco.com>.
On Tue, 11 Jan 2011, Christian Märzinger wrote:
>> PackagePartName commentsPart =
>> PackagingURIHelper.createPartName("/word/comments.xml")
>>
>> comment = opcPackage.getPart(commentsPart);
>>
>> then I try to delete it
>>
>> opcPackage.delete(comment);
OPCPackage doesn't have a delete(PackagePart) method on it...
You want to call opcPackage.deletePart(PackagePartName):
http://poi.apache.org/apidocs/org/apache/poi/openxml4j/opc/OPCPackage.html#deletePart(org.apache.poi.openxml4j.opc.PackagePartName)
This method should work fine, and there are unit tests for it
Nick
Re: Error deleting Part
Posted by Christian Märzinger <ch...@gmail.com>.
Sorry for the wrong code
I try to delete from the opcPackage with the commentsPart
but the error is the same
Am 10.01.2011 01:33, schrieb Christian Märzinger:
> Hello!
>
> I try do delete a part of a docx file.
> first I grab the part with the following code
>
> PackagePartName commentsPart =
> PackagingURIHelper.createPartName("/word/comments.xml")
>
> comment = opcPackage.getPart(commentsPart);
>
> then I try to delete it
>
> opcPackage.delete(comment);
>
>
> In debug the comment part is not null and also I find the part in the
> partlist.
> But I get the error
>
> java.lang.IllegalArgumentException: partName
>
>
> Do I have to delete the relationships manually or something other?
> Thanks
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org