You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Shiva Kumar <sh...@pawaa.com> on 2015/08/18 08:50:12 UTC

How to get a PackagePart object from OPCPackage.

Hi,

I am trying to retrieve a PackagePart object from OPCPackage, I am using
below code right now.

 

OPCPackage  oPkg = OPCPackage.open(docxFin, PackageAccess.READ);

                                List<PackagePart> packageParts =
oPkg.getParts();

                                for (PackagePart part : packageParts)

                                {

 
System.out.println(part.getPartName());

                                }

is there any direct methods like:

oPkg.getPart("/word/styles.xml");

 

Also, how can I create PackagePartName object because it is required to get
PackagePart Object.

 

Thank You

 

SHIVA KUMAR K R

 


Re: How to get a PackagePart object from OPCPackage.

Posted by Nick Burch <ap...@gagravarr.org>.
On Tue, 18 Aug 2015, Shiva Kumar wrote:
> I am trying to retrieve a PackagePart object from OPCPackage, I am using
> below code right now.
>
> is there any direct methods like:
>
> oPkg.getPart("/word/styles.xml");

No. Best bet is to look up the relationship that links the document to the 
style, then call PackagePart.getRelatedPart(relation). The OPC way is 
generally to do things by the relations, not by absolute names

Nick

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