Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Currently I am working on a file management system which developed in c# & asp.net
Where user can store bulk files. Now I want to view all viewable formats of file (i.e. image, ms office, pdf etc) open in browser (without downloading in clients local machine). I already done half of my job i.e. my application working fine for all image files and pdf files. But I facing problem with ms office files (i.e. xls, xlsx, doc, docx, ppt etc) formats. I tried some piece of code
C#
protected void Page_Load(object sender, EventArgs e)
        {
            //Set the appropriate ContentType.
            string FilePath = MapPath("Test/xyz.pdf");
            Response.Buffer = true;
            Response.Clear();
            Response.ClearContent();
            Response.ClearHeaders();
            Response.ContentType = "Application/pdf";
            Response.AddHeader("content-disposition", "inline; filename=\"" + "xyz.pdf" + "\"");
            Response.Write(FilePath);
            Response.End();
        }


This code works fine only for .pdf files but when I changed my content type Response.ContentType for word or excel files Application/msword (for Microsoft Word files) Application/x-msexcel (for Microsoft Excel files) then this code not works. Please guide me what can I do. Should I use any tool like google documents viewer or some thing else.If it is possible only with tool then please suggest me a good tool for this.

Thanks in advance
Posted
Comments
bbirajdar 3-Apr-13 10:03am    
Well.. The day it becomes possible, microsoft will be doomed.. Nobody will buy the licence of MS Office . Everybody will download the free internet browsers and begin working with (xls, xlsx, doc, docx, ppt etc) files..
NileshKRathod 3-Apr-13 10:07am    
Here i am asking about view files in browser not creating or editing files online. This is already works in google drive, sky drive and other online file storage web applications.

1 solution

In brief: the Office formats are now publicly available and standardized (please see links below), but they are not supported by Web standards, so you would need to represent their content and show as HTML.

Please see my past answer on how to deal with these files. You should devise your own mapping to HTML and implementation of generation of the HTML content. Please see:
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..[^].

—SA
 
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