1

我正在尝试制作一个小程序来将自动更正更改应用于现有文档。我正在使用 docX 库。我的问题是,您如何使用 docX 库迭代(或循环)文档中的每个单词,以检查它是否需要更正(我已经在 a 中插入了所有自动更正条目list<T>)。

4

1 回答 1

2

试试这个...

DocX document = DocX.Load( <document path> );

foreach(Novacode.Paragraph item in document.Paragraphs) {
  
  // use this if you need whole text of a paragraph
  string paraText = item.Text;
  
  // use this if you need word by word
  foreach(var data in item.MagicText) {
    
    string word = data.text;
  }
}

于 2015-06-11T03:53:39.180 回答