当前位置: 首页>>代码示例>>C#>>正文


C# PackagePart.AddExternalRelationship方法代码示例

本文整理汇总了C#中NPOI.OpenXml4Net.OPC.PackagePart.AddExternalRelationship方法的典型用法代码示例。如果您正苦于以下问题:C# PackagePart.AddExternalRelationship方法的具体用法?C# PackagePart.AddExternalRelationship怎么用?C# PackagePart.AddExternalRelationship使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NPOI.OpenXml4Net.OPC.PackagePart的用法示例。


在下文中一共展示了PackagePart.AddExternalRelationship方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GenerateRelationIfNeeded

        /**
         * Generates the relation if required
         */
        internal void GenerateRelationIfNeeded(PackagePart sheetPart)
        {
            if (_externalRel == null && NeedsRelationToo())
            {
                // Generate the relation
                PackageRelationship rel =
                        sheetPart.AddExternalRelationship(_location, XSSFRelation.SHEET_HYPERLINKS.Relation);

                // Update the r:id
                _ctHyperlink.id = rel.Id;
            }
        }
开发者ID:WPG,项目名称:npoi,代码行数:15,代码来源:XSSFHyperlink.cs

示例2: 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);
            }
        }
    }
开发者ID:89sos98,项目名称:npoi,代码行数:36,代码来源:PackageHelper.cs


注:本文中的NPOI.OpenXml4Net.OPC.PackagePart.AddExternalRelationship方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。