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

效果:

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM