Click here to Skip to main content
14,878,179 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Can I Open Word Document In Browser Or Calling Ms Word Application Using Html 5 ..?
Posted

You cannot. Word documents are not part of W3 standard. You probably saw many sites doing that. They just interpret the files on server side and represent it content with HTML. You can do the same. You need to develop some mapping between HTML and Word documents relevant to your purpose. You can use Open XML SDK:
http://www.microsoft.com/en-us/download/details.aspx?id=30425[^].

By the way, Microsoft warns about using Office Interop in server settings:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q257757#kb2[^],
http://support.microsoft.com/kb/257757/en-us[^].

This way, you can support new XML-based Office formats (such as .DOCX, .XLSX), ECMA-376 standard:
http://en.wikipedia.org/wiki/Microsoft_Office_XML_formats[^],
http://en.wikipedia.org/wiki/Office_Open_XML[^].

This way, you can work without Office installed. Also, the documents are supported by 3rd-party software. Please see my past answers:
Convert Office-Documents to PDF without interop[^],
Need a rather unique WPF text editor control[^],
Hi how can i display word file in windows application using c#.net[^],
Read a word file without using Interop.word dll...Do not want to install word in IIS..[^].

This is another option: http://npoi.codeplex.com/[^].

—SA
   
Comments
Joezer BH 6-Feb-14 4:43am
   
Very good answer.
5ed!
   
Thank you very much.
—SA
Just embed Google Doc Viewer through an iframe and specify the DOC file you want to display. This is the code you should add:

HTML
<iframe src="http://docs.google.com/gview?url=http://infolab.stanford.edu/pub/papers/google.pdf&embedded=true" style="width:600px; height:500px;" frameborder="0"></iframe>


Then you just need to set up your own document file to the "url" query string param and that's it! You can display not just DOC but any other file supported by the viewer like pdf, xls, etc. in any browser!
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900