OpenXmlElement Class

Posted ein-key5205

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了OpenXmlElement Class相关的知识,希望对你有一定的参考价值。

https://docs.microsoft.com/en-us/dotnet/api/documentformat.openxml.openxmlelement?view=openxml-2.8.1

Represents a base class that all elements in an Office Open XML document derive from. Represents a base class for all elements in an Office Open XML document.

1 public abstract class OpenXmlElement : ICloneable, System.Collections.Generic.IEnumerable<DocumentFormat.OpenXml.OpenXmlElement>
Inheritance
OpenXmlElement
Derived
Implements

Examples

The following code example shows how to access elements at the same level in a word-processing document. The test file used in the example contains the text “OpenXml Element.”

using System;  
using System.Collections.Generic;  
using System.Linq;  
using DocumentFormat.OpenXml.Packaging;  
using DocumentFormat.OpenXml.Wordprocessing;  
  
namespace OpenXmlElement  
{  
    class Program  
    {  
        // This code example shows how to access elements at the same level    
        // in a word-processing document.   
        // The example is using a file that contains the text "OpenXml Element."  
        static void Main(string[] args)  
        {  
            string fileName = @"C:UsersPublicDocumentsAccessElementsSameLevel.docx";  
            using (WordprocessingDocument wordprocessingDocument =   
                WordprocessingDocument.Open(fileName, false))  
            {  
                // Create a Body object.  
                DocumentFormat.OpenXml.Wordprocessing.Body body =  
                    wordprocessingDocument.MainDocumentPart.Document.Body;  
  
                // Create a Paragraph object.  
                DocumentFormat.OpenXml.Wordprocessing.Paragraph firstParagraph =  
                    body.Elements<Paragraph>().FirstOrDefault();  
  
                // Get the first child of an OpenXmlElement.  
                 DocumentFormat.OpenXml.OpenXmlElement firstChild = firstParagraph.FirstChild;  
                IEnumerable<Run> elementsAfter =  
                    firstChild.ElementsAfter().Where(c => c is Run).Cast<Run>();  
  
                // Get the Run elements after the specified element.  
                Console.WriteLine("Run elements after the first child are: ");  
                foreach (DocumentFormat.OpenXml.Wordprocessing.Run run in elementsAfter)  
                {  
                    Console.WriteLine(run.InnerText);  
                }  
                Console.ReadKey();  
            }  
        }  
    }  
}  
// Output:  
// Run elements after the first child are:  
// OpenXml  
//  Element

 

以上是关于OpenXmlElement Class的主要内容,如果未能解决你的问题,请参考以下文章

Xcode 快速开发 代码块

解决spring-boot启动中碰到的问题:Cannot determine embedded database driver class for database type NONE(转)(代码片段

java 反射代码片段

Xcode 快速开发 代码块 快捷键

14.VisualVM使用详解15.VisualVM堆查看器使用的内存不足19.class文件--文件结构--魔数20.文件结构--常量池21.文件结构访问标志(2个字节)22.类加载机制概(代码片段

bootspring???????????????Date??????????????????????????????????????????????????????????????????(代码片段