how to read word doc file on web page in asp.net with c# ?
thank in adv...
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Debra DuchenePosted Jun 10, 2014, 2:48 AM
For example here is how you would read a Word file (DOC or DOCX) with C#:
DocumentModel doc = DocumentModel.Load("Document.doc", LoadOptions.DocDefault);
And if you need to display it to the client's browser then there are few ways you can try. You can convert your loaded Word file into a PDF file in .NET and redirect a client to it.
doc.Save("Document.pdf", SaveOptions.PdfDefault);
Or you could convert it to an image and display it in your page, or you could just convert it to a HTML file. The conversion is always achieved in the same manner, you just need to specify the SaveOptions.
Also if you want to stream a file to the client's browser (download the file), then you can export/stream your Word file in ASP.NET through the Response like the following:
doc.Save(this.Response, "Document.docx");
Mark ConorsPosted Mar 11, 2013, 3:18 AM
You might want to look at these articles:
http://www.codeproject.com/Articles/3959/Microsoft-Word-Documents-from-ASP-NET
http://www.mindstick.com/Articles/5cd1b721-9b94-4ea0-bd6e-2bb157401069/
http://zirmandli.wordpress.com/2007/07/04/read-word-doc-using-c/
Or you may want to use some .Net components:
http://eleriumsoft.com/Word_NET/WordReader/Examples/Read_Word_Document.aspx
Sharon WhitePosted Feb 25, 2013, 9:55 PM
The following code is used to open Word with downloading.
protected void Button1_Click(object sender, System.EventArgs e)
{
//Create word document
Document document = new Document();
document.LoadFromFile("E:\\2013.02.18News.docx", FileFormat.Docx2010);
//Save doc file.
document.SaveToFile("Sample.doc", FileFormat.Doc,Response, HttpContentType.Attachment);
}
I use a ASP.NET Word component.
Satyapriya NayakPosted Feb 25, 2013, 1:53 AM