Below is my code to read a doc/docs file.
it can read, but the output format not exactly as in the docs, if that any way to display exactly format in aspx?
protected void Button2_Click(object sender, EventArgs e)
{
var wordApp = new Microsoft.Office.Interop.Word.ApplicationClass();
string strFilePath = @"C:\Users\Roy\Desktop\News.doc";
object objFile = strFilePath;
object objNull = System.Reflection.Missing.Value;
object objReadOnly = true;
//Open Document
Microsoft.Office.Interop.Word.Document Doc
= wordApp.Documents.Open(ref objFile, ref objNull,
ref objReadOnly, ref objNull,
ref objNull, ref objNull, ref objNull,
ref objNull, ref objNull, ref objNull,
ref objNull, ref objNull, ref objNull,
ref objNull, ref objNull, ref objNull);
int i = 1;
foreach (Microsoft.Office.Interop.Word.Paragraph objParagraph
in Doc.Paragraphs)
{
try
{
Label1.Text += Doc.Paragraphs[i].Range.Text;
}
catch (Exception ex)
{
throw ex;
}
i++;
}
wordApp.Quit(ref objNull, ref objNull, ref objNull);
}
How to use the WebBrowser control to open Office documents in Visual C# 2005 or in Visual C# .NET may help you. There’s another article here http://forums.asp.net/t/1068814.aspx/1 which opens up document in user’s Word embedded in browser which may help if everything else fails. But I guess it requires user to have Office installed.