Read from word document line by line

前端 未结 3 1646
孤独总比滥情好
孤独总比滥情好 2020-11-27 18:25


I\'m trying to read a word document using C#. I am able to get all text but I want to be able to read line by line and store in a list and bind

3条回答
  •  一整个雨季
    2020-11-27 19:04

    The above code is correct, but it's too slow. I have improved the code, and it's much faster than the above one.

    List data = new List();
    Application app = new Application();
    Document doc = app.Documents.Open(ref readFromPath);
    
    foreach (Paragraph objParagraph in doc.Paragraphs)
        data.Add(objParagraph.Range.Text.Trim());
    
    ((_Document)doc).Close();
    ((_Application)app).Quit();
    

提交回复
热议问题