how to open a word or excel file inside a browser

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sheikhmdirfan
Forum Newbie
Posts: 22
Joined: Tue Jan 20, 2009 12:21 am

how to open a word or excel file inside a browser

Post by sheikhmdirfan »

Dear All,


Is there a way using which we can display a word or excel file inside the browser window...
If yes, then please let me know..

Any help is highly appreciated...

Thanks in advance..
Mark Baker
Forum Regular
Posts: 710
Joined: Thu Oct 30, 2008 6:24 pm

Re: how to open a word or excel file inside a browser

Post by Mark Baker »

Not really a PHP question, but

Depends if the user has word/excel installed or not.... and on what precisely you mean by "inside the browser window". If you simply want the user to be able to see word or excel files that exist on the server, then you can offer them a download. This typically prompts for "save or open" the file, and if they have an appropriate program on their PC to allow them to read that file type, then the "open" option will normally open that application. Precise behaviour may vary between browsers and OS platforms, but as you're talking about word and excel, I'd assume most of your users are on a windows platform.

If you mean literally "in the browser", like PDFs or similar, then you'd need to create a browser plug-in capable of reading these files and displaying them.... not the easiest of tasks, especially if you are a novice developer.

Another alternative would be to use a library or tool capable of taking word/excel files, and converting them to HTML.
User avatar
juma929
Forum Commoner
Posts: 72
Joined: Wed Jun 17, 2009 9:41 am

Re: how to open a word or excel file inside a browser

Post by juma929 »

Hello,

I've done this in the past with excel. As mentioned it does depend heavily on your OS / Browser versions so it wont exactly be a user friendly solution. Rather offer them the download. If however you want to go ahead and open an excel doc in the window itself whenever possible I believe you can set the appropriate header content type but you will need to research it as I havnt done this in a while, as mentioned, I just offer the download or email it to the user.

Thanks.
User avatar
Darhazer
DevNet Resident
Posts: 1011
Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria

Re: how to open a word or excel file inside a browser

Post by Darhazer »

In order to force a file to be opened inside the browser, not downloading it, use the <embed> tag. However, as said in previous posts, user will see it only if it have appropriate plugin
User avatar
a94060
Forum Regular
Posts: 543
Joined: Fri Feb 10, 2006 4:53 pm

Re: how to open a word or excel file inside a browser

Post by a94060 »

http://www.codeplex.com/PHPExcel May be of help. As for Word, i dont know one.
Post Reply