Click here to Skip to main content
15,886,422 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need the following requirement.

The user should be able to view and edit the doc,xls,ppt etc file in the browser .
These files should not open with application,mean to say that i should not get "open with dialog box

I have put my efforts and find the solution to display pdf,jpg formatted files in the browser when the user clicks on some link.

I am also able to display the MSword file in the browser which contains text only and also without formatting ,unable to display the images,tables of Msdocument in the browsers.


I am giving my efforts below.

If anyone could help i will be very thankful to them


Thanks in Advance

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.Office.Interop.Word;
using Microsoft.Office.Interop;
using Microsoft.Office;
public partial class MSWord_Display : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.Params.Count > 0)
        {
            if (Convert.ToString(Request["word"]).Length > 0)
            {
                string name = @"D:\prasad\working Folder\sandhya_1.doc";
                //ApplicationClass
                ApplicationClass oWordApp = new ApplicationClass();
                object fileName = name;
                object readOnly = true; //open with dialog will not be opened if it is true
                object isVisible = true;
                object missing = System.Reflection.Missing.Value;
                Document oWordDoc = oWordApp.Documents.Open(
                                            ref fileName,
                                            ref missing, ref  readOnly,
                                            ref missing, ref missing, ref missing,
                                            ref missing, ref missing, ref missing,
                                            ref missing, ref missing, ref isVisible,
                                            ref missing, ref missing, ref missing, ref missing);
                oWordDoc.Activate();
                txtArea.InnerHtml = oWordDoc.Content.Text;
            }
            else
            {
                divMsword.InnerHtml = "<b> Document name is missing: </b>";
            }
        }
    }
    }
Posted
Updated 22-Aug-11 17:43pm
v3
Comments
walterhevedeich 23-Aug-11 0:59am    
What problem exactly are you having with this code?

You will not be able to build an editor for MSWord files in the browser. If you did your research you would see the format of a Word document in this version is very complex and very difficult to represent in an HTML page. You stand a chance with later versions off MS Word since they use the Open XML standard.
 
Share this answer
 
how can i any type of file in browser online using asp.net
 
Share this answer
 

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