Aspose. word reads the content of the word Section, aspose. wordword

Source: Internet
Author: User

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();  }     }

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.