本文整理汇总了C#中NPOI.OpenXml4Net.OPC.OPCPackage.GetPackageProperties方法的典型用法代码示例。如果您正苦于以下问题:C# OPCPackage.GetPackageProperties方法的具体用法?C# OPCPackage.GetPackageProperties怎么用?C# OPCPackage.GetPackageProperties使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NPOI.OpenXml4Net.OPC.OPCPackage
的用法示例。
在下文中一共展示了OPCPackage.GetPackageProperties方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Clone
/**
* Clone the specified namespace.
*
* @param pkg the namespace to clone
* @param file the destination file
* @return the Cloned namespace
*/
public static OPCPackage Clone(OPCPackage pkg, string path)
{
OPCPackage dest = OPCPackage.Create(path);
PackageRelationshipCollection rels = pkg.Relationships;
foreach (PackageRelationship rel in rels)
{
PackagePart part = pkg.GetPart(rel);
PackagePart part_tgt;
if (rel.RelationshipType.Equals(PackageRelationshipTypes.CORE_PROPERTIES))
{
CopyProperties(pkg.GetPackageProperties(), dest.GetPackageProperties());
continue;
}
dest.AddRelationship(part.PartName, (TargetMode)rel.TargetMode, rel.RelationshipType);
part_tgt = dest.CreatePart(part.PartName, part.ContentType);
Stream out1 = part_tgt.GetOutputStream();
IOUtils.Copy(part.GetInputStream(), out1);
out1.Close();
if (part.HasRelationships)
{
Copy(pkg, part, dest, part_tgt);
}
}
dest.Close();
//the temp file will be deleted when JVM terminates
//new File(path).deleteOnExit();
return OPCPackage.Open(path);
}
示例2: POIXMLProperties
public POIXMLProperties(OPCPackage docPackage)
{
this.pkg = docPackage;
// Core properties
core = new CoreProperties((PackagePropertiesPart)pkg.GetPackageProperties());
// Extended properties
PackageRelationshipCollection extRel =
pkg.GetRelationshipsByType(PackageRelationshipTypes.EXTENDED_PROPERTIES);
if (extRel.Size == 1)
{
extPart = pkg.GetPart(extRel.GetRelationship(0));
ExtendedPropertiesDocument props = ExtendedPropertiesDocument.Parse(
extPart.GetInputStream()
);
ext = new ExtendedProperties(props);
}
else
{
extPart = null;
ext = new ExtendedProperties((ExtendedPropertiesDocument)NEW_EXT_INSTANCE.Copy());
}
// Custom properties
PackageRelationshipCollection custRel =
pkg.GetRelationshipsByType(PackageRelationshipTypes.CUSTOM_PROPERTIES);
if (custRel.Size == 1)
{
custPart = pkg.GetPart(custRel.GetRelationship(0));
CustomPropertiesDocument props = CustomPropertiesDocument.Parse(
custPart.GetInputStream()
);
cust = new CustomProperties(props);
}
else
{
custPart = null;
cust = new CustomProperties((CustomPropertiesDocument)NEW_CUST_INSTANCE.Copy());
}
}
示例3: CompareProperties
private void CompareProperties(OPCPackage p)
{
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
DateTime expectedDate = DateTime.Parse("2007/05/12T08:00:00Z").ToUniversalTime();
// Gets the core properties
PackageProperties props = p.GetPackageProperties();
Assert.AreEqual("MyCategory", props.GetCategoryProperty());
Assert.AreEqual("MyContentStatus", props.GetContentStatusProperty()
);
Assert.AreEqual("MyContentType", props.GetContentTypeProperty());
Assert.AreEqual(expectedDate, props.GetCreatedProperty());
Assert.AreEqual("MyCreator", props.GetCreatorProperty());
Assert.AreEqual("MyDescription", props.GetDescriptionProperty());
Assert.AreEqual("MyIdentifier", props.GetIdentifierProperty());
Assert.AreEqual("MyKeywords", props.GetKeywordsProperty());
Assert.AreEqual("MyLanguage", props.GetLanguageProperty());
Assert.AreEqual("Julien Chable", props.GetLastModifiedByProperty()
);
Assert.AreEqual(expectedDate, props.GetLastPrintedProperty());
Assert.AreEqual(expectedDate, props.GetModifiedProperty());
Assert.AreEqual("2", props.GetRevisionProperty());
Assert.AreEqual("MySubject", props.GetSubjectProperty());
Assert.AreEqual("MyTitle", props.GetTitleProperty());
Assert.AreEqual("2", props.GetVersionProperty());
}