Aspose. word reads the content of the word Section, aspose. wordword
Note: Indicate the original source and author information of the document for reprinting.
Aspose. word plug-in download link: http://pan.baidu.com/s/1qXIgOXY password: wsj2
Cause of use: No office installation required, no compatibility issues, crack version restrictions
Code:
Public ParagraphCollection WordParagraphs (string fileName) {Document doc = new Document (fileName); if (doc. firstSection. body. paragraphs. count> 0) {return doc. firstSection. body. paragraphs; // all Paragraphs in word} return null ;}
public string GetWordParagraphs(int index){ var phs = _word.WordParagraphs(Server.MapPath(model.WordFpath)); return phs[i].GetText();}
The following is an example of using Microsoft. Office. Interop. Word to read paragraphs (flexible operations but not compatible)
public class WordHelper{ private _Document doc = null; public WordHelper() { objApp = new Application(); } public void Open(string fileName) { object objDoc = fileName; object objMissing = Missing.Value; doc = objApp.Documents.Open(ref objDoc); doc.Activate(); } public Paragraphs GetParagraphs() { return objApp.ActiveDocument.Paragraphs; } public string GetParagraphs(int index) { return objApp.ActiveDocument.Paragraphs[index].Range.Text; } public void Close() { objApp.ActiveDocument.Close(); objApp.Quit(); } }