I'm trying to fetch the content of the MsWord file and load it into a div tag.

Can anybody tell, How to get the content of a word file with the same alignment.

I'm using Interop.dll

Here is the code,

using Microsoft.Office.Interop.Word;
using System;
using System.Text;

 protected void Page_Load(object sender, EventArgs e)
        {
            // Open a doc file.
            Application application = new Application();
            Document document = application.Documents.Open(@"D:\MyDocument.docx");

            StringBuilder strRdr = new StringBuilder();
            // Loop through all words in the document.
            int count = document.Words.Count;
            for (int i = 1; i <= count; i++)
            {
                strRdr.Append(document.Words[i].Text);
                divContent.InnerHtml =Convert.ToString(strRdr);

            }
            // Close word.
            application.Quit();
        }

It works fine. but it reads only Text. But I would like to fetch the entire content with proper alignment.

Please help me.

Thank You.

Related posts

Recent Viewed