Sfoglia il codice sorgente

解决word最后一行字符不换行则读不了最后一行内容的bug

tangs 7 anni fa
parent
commit
7b9b177a18
2 ha cambiato i file con 3 aggiunte e 0 eliminazioni
  1. 3 0
      WindowsFormsApp1/WordAnalyze.cs
  2. BIN
      build/WindowsFormsApp1.exe

+ 3 - 0
WindowsFormsApp1/WordAnalyze.cs

@@ -35,6 +35,8 @@ namespace WordAnalyze
             {
                 doc = app.Documents.Open(ref fn);
 
+                doc.Paragraphs.Add();
+
                 Word.Paragraphs garapraph = doc.Paragraphs; // 源文件的内容
                 bool insert = false; //判断是否有插入数据到新文档中,如果有则保存新word,否则直接关掉新word
                 int fileIndex = 1; // 切割后word的文件序号,例子: test1.doc, test2.doc
@@ -84,6 +86,7 @@ namespace WordAnalyze
             finally
             {
                 if (doc != null) {
+                    doc.Undo();
                     doc.Close();
                 }
                 if (app != null)

BIN
build/WindowsFormsApp1.exe