OpenXml读取word内容(三)

内容和表格内容一起读;

word内容:

代码:

 1         public static void ReadWordByOpenXml(string path)
 2         {
 3             using (WordprocessingDocument doc = WordprocessingDocument.Open(path, true))
 4             {
 5                 Body body = doc.MainDocumentPart.Document.Body;
 6                 foreach (var inst in body.Elements<OpenXmlElement>())
 7                 {
 8                     Console.WriteLine(inst.InnerText);
 9                 }
10             }
11         }
View Code

效果:

 

posted @ 2017-12-20 22:36  *飞*  阅读(1558)  评论(0)    收藏  举报