本文整理汇总了C#中NPOI.OpenXml4Net.OPC.OPCPackage.ContainPart方法的典型用法代码示例。如果您正苦于以下问题:C# OPCPackage.ContainPart方法的具体用法?C# OPCPackage.ContainPart怎么用?C# OPCPackage.ContainPart使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NPOI.OpenXml4Net.OPC.OPCPackage
的用法示例。
在下文中一共展示了OPCPackage.ContainPart方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Copy
/**
* Recursively copy namespace parts to the destination namespace
*/
private static void Copy(OPCPackage pkg, PackagePart part, OPCPackage tgt, PackagePart part_tgt) {
PackageRelationshipCollection rels = part.Relationships;
if(rels != null)
foreach (PackageRelationship rel in rels) {
PackagePart p;
if(rel.TargetMode == TargetMode.External){
part_tgt.AddExternalRelationship(rel.TargetUri.ToString(), rel.RelationshipType, rel.Id);
//external relations don't have associated namespace parts
continue;
}
Uri uri = rel.TargetUri;
if(uri.Fragment != null) {
part_tgt.AddRelationship(uri, (TargetMode)rel.TargetMode, rel.RelationshipType, rel.Id);
continue;
}
PackagePartName relName = PackagingUriHelper.CreatePartName(rel.TargetUri);
p = pkg.GetPart(relName);
part_tgt.AddRelationship(p.PartName, (TargetMode)rel.TargetMode, rel.RelationshipType, rel.Id);
PackagePart dest;
if(!tgt.ContainPart(p.PartName)){
dest = tgt.CreatePart(p.PartName, p.ContentType);
Stream out1 = dest.GetOutputStream();
IOUtils.Copy(p.GetInputStream(), out1);
out1.Close();
Copy(pkg, p, tgt, dest);
}
}
}