コード例 #1
0
ファイル: TestEntities.cs プロジェクト: zfh521/Open-XML-SDK
        /// <summary>
        /// Deleting chartTrackingReferenceBased element
        /// </summary>
        public void DeleteElements(Stream stream, VerifiableLog log)
        {
            using (PresentationDocument package = PresentationDocument.Open(stream, true))
            {
                PresentationPropertiesExtension presentationPropertiesExtension = package.PresentationPart.PresentationPropertiesPart.PresentationProperties.PresentationPropertiesExtensionList.Descendants <PresentationPropertiesExtension>().Where(e => e.Uri == ChartTrackingReferenceBasedExtUri).Single();
                P15.ChartTrackingReferenceBased chartTrackingReferenceBased     = presentationPropertiesExtension.Descendants <P15.ChartTrackingReferenceBased>().Single();

                chartTrackingReferenceBased.Remove();
                presentationPropertiesExtension.Remove();

                log.Pass("Deleted chartTrackingReferenceBased element.");
            }
        }
コード例 #2
0
ファイル: TestEntities.cs プロジェクト: yuekunge/Open-XML-SDK
        /// <summary>
        /// Deleting chartTrackingReferenceBased element
        /// </summary>
        /// <param name="filePath">Target faile path</param>
        /// <param name="log">Logger</param>
        public void DeleteElements(string filePath, VerifiableLog log)
        {
            using (PresentationDocument package = PresentationDocument.Open(filePath, true))
            {
                try
                {
                    PresentationPropertiesExtension presentationPropertiesExtension = package.PresentationPart.PresentationPropertiesPart.PresentationProperties.PresentationPropertiesExtensionList.Descendants <PresentationPropertiesExtension>().Where(e => e.Uri == this.ChartTrackingReferenceBasedExtUri).Single();
                    P15.ChartTrackingReferenceBased chartTrackingReferenceBased     = presentationPropertiesExtension.Descendants <P15.ChartTrackingReferenceBased>().Single();

                    chartTrackingReferenceBased.Remove();
                    presentationPropertiesExtension.Remove();

                    log.Pass("Deleted chartTrackingReferenceBased element.");
                }
                catch (Exception e)
                {
                    log.Fail(e.Message);
                }
            }
        }