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()); }
/** * Copy core namespace properties * * @param src source properties * @param tgt target properties */ private static void CopyProperties(PackageProperties src, PackageProperties tgt) { tgt.SetCategoryProperty(src.GetCategoryProperty()); tgt.SetContentStatusProperty(src.GetContentStatusProperty()); tgt.SetContentTypeProperty(src.GetContentTypeProperty()); tgt.SetCreatorProperty(src.GetCreatorProperty()); tgt.SetDescriptionProperty(src.GetDescriptionProperty()); tgt.SetIdentifierProperty(src.GetIdentifierProperty()); tgt.SetKeywordsProperty(src.GetKeywordsProperty()); tgt.SetLanguageProperty(src.GetLanguageProperty()); tgt.SetRevisionProperty(src.GetRevisionProperty()); tgt.SetSubjectProperty(src.GetSubjectProperty()); tgt.SetTitleProperty(src.GetTitleProperty()); tgt.SetVersionProperty(src.GetVersionProperty()); }
public void TestGetPropertiesLO() { // Open the namespace OPCPackage pkg1 = OPCPackage.Open(OpenXml4NetTestDataSamples.OpenSampleStream("51444.xlsx")); PackageProperties props1 = pkg1.GetPackageProperties(); Assert.AreEqual(null, props1.GetTitleProperty()); props1.SetTitleProperty("Bug 51444 fixed"); MemoryStream out1 = new MemoryStream(); pkg1.Save(out1); out1.Close(); OPCPackage pkg2 = OPCPackage.Open(new MemoryStream(out1.ToArray())); PackageProperties props2 = pkg2.GetPackageProperties(); props2.SetTitleProperty("Bug 51444 fixed"); }