OpenXML應用-抓取Word中特定表格與句子,轉成String型別(Find special table and paragraph in word,and convert to String type)
本文參考: https://stackoverflow.com/questions/45466325/how-to-read-values-from-a-table-in-a-word-doc-using-c-sharp 還記得之前介紹" OpenXML介紹與應用-保留word特定表格與句子顯示在網頁上(OpenXML keep special(keyword) table and paragraph) " ,由於微軟的OpenXmlPowerTools品質不穩定,有些word檔就是轉譯失敗,但又是必要的需求,只好動手自己刻。 需求:抓到word中有出現特定關鍵字的表格與句子(且要包含數字),留下來展示在網頁上。 Step1:將你的word檔案打開,用MemoryStream讀,讀到後再用WordprocessingDocument打開她。 using (MemoryStream memoryStream = new MemoryStream()) { memoryStream.Write((byte[])Session["FileUpload1.FileBytes"], 0, (int)Session["FileUpload1.FileBytes.Length"]); using (WordprocessingDocument wDoc = WordprocessingDocument.Open(memoryStream, true)) ...