how to read the conents of word file on web page [modified]
-
hy, can any one tell me that how can i read the contents of a MS word(.doc) file on a webpage(.aspx page). i tried to use filestream but whenevr i run it..i get a option to open or download the doc file which resluts in opening the word file but not the content of the word file on the web page. the code that i used was Response.ContentType = "application/ms-word"; Response.AddHeader("content-disposition", "attachment; filename=SFA & CRM.doc"); string a = Server.MapPath("SFA & CRM.doc"); FileStream sourceFile = new FileStream(a, FileMode.Open); long FileSize; FileSize = sourceFile.Length; byte[] getContent = new byte[(int)FileSize]; sourceFile.Read(getContent, 0, (int)sourceFile.Length); sourceFile.Close(); Response.BinaryWrite(getContent); plz helpl me out.. regards
modified on Friday, October 10, 2008 4:00 AM
-
hy, can any one tell me that how can i read the contents of a MS word(.doc) file on a webpage(.aspx page). i tried to use filestream but whenevr i run it..i get a option to open or download the doc file which resluts in opening the word file but not the content of the word file on the web page. the code that i used was Response.ContentType = "application/ms-word"; Response.AddHeader("content-disposition", "attachment; filename=SFA & CRM.doc"); string a = Server.MapPath("SFA & CRM.doc"); FileStream sourceFile = new FileStream(a, FileMode.Open); long FileSize; FileSize = sourceFile.Length; byte[] getContent = new byte[(int)FileSize]; sourceFile.Read(getContent, 0, (int)sourceFile.Length); sourceFile.Close(); Response.BinaryWrite(getContent); plz helpl me out.. regards
modified on Friday, October 10, 2008 4:00 AM
Hi, Please know that Word .doc files are in a proprietary Microsoft binary format. They can only be interpreted correctly by the Office Word engine or a third party control suited for this purpose. You may consider using the Office PIA (Primary Interop Assemblies), automate Word and open the document in it, and extract the relevant portions from the same, preserving the formatting. Hope this helps.
Regards, John Adams ComponentOne LLC