我正在使用Microsoft.Office.Interop.Word
在C#(3.5)中閱讀word文檔。逐行讀取,將行分割成數組[]並處理每行的單詞,並根據某些業務邏輯替換某些單詞,並在替換單詞後,用換行代替整行。如何逐行閱讀MS Word段落和表格內容
直到現在,每件事情都很好。
現在我有一些word文檔,那些有段和表。我想逐個讀取表格的每一列,並替換特定列中列的內容。
更新
使用辦公自動化
1. Opening word file.
2. Moving cursor to top of the document
3. Selecting first line using (`wordApp.Selection.endKey`) and processing all words
4. After processing the words replacing the selected line with the processed line.
5. Using wordApp.Selection.MoveDown(ref lineCount, ref countPage, ref MISSING);
moving next line processed further.
問題: 1.當讀取表使用wordApp.Selection.endKey
時,我想處理所有列的讀取僅第一列數據。 有什麼方法可以確定內容是段落還是表格?
http://stackoverflow.com/questions/10696591/retrieving-table-data-from-a-doc-file-using-c-sharp。請參閱此處以從表 – gout
中檢索值除了由@gout鏈接的答案之外,Word互操作的Table接口還包含一個Columns屬性,該屬性與該鏈接中使用的Rows屬性非常相似 –