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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Satyapriya NayakRank #47 · 31.5K reputationPosted Feb 24, 2013, 8:53 PM EST
Sharon White50 reputationPosted Feb 25, 2013, 4:55 PM EST
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.
Mark Conors8 reputationPosted Mar 10, 2013, 11:18 PM EDT
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
Debra Duchene8 reputationPosted Jun 9, 2014, 10:48 PM EDT
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");