欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

OpenXml讀取word內(nèi)容的實(shí)例

 更新時(shí)間:2017年12月12日 08:56:12   作者:*飛*  
下面小編就為大家分享一篇OpenXml讀取word內(nèi)容的實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧

OpenXml讀取word內(nèi)容注意事項(xiàng)

1、使用OpenXml讀取word內(nèi)容,word后綴必須是".docx";如果word后綴是".doc"需要轉(zhuǎn)成".docx"后,才可以讀??;

2、需要引入相關(guān)dll;"WindowsBase.dll"、“DocumentFormat.OpenXml.dll”;

3、word大小>0字節(jié)(word大小為0字節(jié)會(huì)報(bào)錯(cuò));

word內(nèi)容

相關(guān)代碼

 

static void Main(string[] args)
  {
   string wordPathStr = @"C:\Users\user\Desktop\新建文件夾 (2)\5.docx";
   using (WordprocessingDocument doc = WordprocessingDocument.Open(wordPathStr, true))
   {
    Body body = doc.MainDocumentPart.Document.Body;
    foreach (var paragraph in body.Elements<Paragraph>())
    {
     Console.WriteLine(paragraph.InnerText);
    }
   }
   Console.ReadLine();
  }

控制臺(tái)顯示

以上這篇OpenXml讀取word內(nèi)容的實(shí)例就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論