Word + PHP

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
Petrini
Forum Newbie
Posts: 3
Joined: Mon Apr 12, 2010 3:30 pm

Word + PHP

Post by Petrini »

Hello guys, I'm not a master in PHP and I've got a little problem;
I have a word file (doc), and inside this file there's a table in a certain local, so I must get the table information and save it as a single file.
I'm trying to use COM but this thing practically has no useful documentation despite some examples of how to open a file and put some text in it.
Does anyone have any examples or documentation which could help me?
Thanks a lot
JakeJ
Forum Regular
Posts: 675
Joined: Thu Dec 10, 2009 6:27 pm

Re: Word + PHP

Post by JakeJ »

This is just off the top of my head because I've never done it but the new versions of word save the files as .docx so there is an XML schema, you should be able to read that in to PHP and get your info. I'm assuming of course you have the ability to save it as a .docx file.
Petrini
Forum Newbie
Posts: 3
Joined: Mon Apr 12, 2010 3:30 pm

Re: Word + PHP

Post by Petrini »

Actually I don't, I have to deal with the format given and sadly I can't change it. Well, I could change it but the idea of automation would simply disappear.
Thank you anyway!
JakeJ
Forum Regular
Posts: 675
Joined: Thu Dec 10, 2009 6:27 pm

Re: Word + PHP

Post by JakeJ »

I found this but I can't vouch for it. Give it a try.

http://www.phpwordlib.motion-bg.com/
User avatar
omniuni
Forum Regular
Posts: 738
Joined: Tue Jul 15, 2008 10:50 pm
Location: Carolina, USA

Re: Word + PHP

Post by omniuni »

I'm afraid your best option (and this is a stretch, mind you) would be to copy and paste the document out of Word into a WYSIWYG editor in your browser, and parse the table out of the output. If you use something like HTMLawed, you should be able to remove most of Word's terrible markup, and then extracting the <table> should be easy. Even if you need to open it again with Word, Word WILL open an HTML file, so... yeah, that might work. :?
eskio
Forum Commoner
Posts: 66
Joined: Tue Apr 01, 2008 1:00 am

Re: Word + PHP

Post by eskio »

Hi,
Convert your word file to xl or copy your table to xl file. You can read easily an XL file using PHPExcel phpexcel.codeplex.com/Wikipage
Petrini
Forum Newbie
Posts: 3
Joined: Mon Apr 12, 2010 3:30 pm

Re: Word + PHP

Post by Petrini »

Ok, thank you!
You all gave me some good ideas, and I'm gonna try everything I can :)
User avatar
Technocrat
Forum Contributor
Posts: 127
Joined: Thu Oct 20, 2005 7:01 pm

Re: Word + PHP

Post by Technocrat »

I need to be up front, I have gotten this to work, and it works so-so. But it requires a number of things to be installed and thus you need root access to the server or the ability for someone to do it for you. But you can use this solution:
viewtopic.php?f=1&t=76452
Post Reply