Click here to Skip to main content
14,668,412 members
Rate this:
Please Sign up or sign in to vote.
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

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?

Rate this:
Please Sign up or sign in to vote.

Solution 1

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.
   
Rate this:
Please Sign up or sign in to vote.

Solution 2

how can i any type of file in browser online using asp.net
   

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100