Page 1 of 1
Word + PHP
Posted: Mon Apr 12, 2010 3:45 pm
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
Re: Word + PHP
Posted: Mon Apr 12, 2010 6:06 pm
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.
Re: Word + PHP
Posted: Mon Apr 12, 2010 10:08 pm
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!
Re: Word + PHP
Posted: Mon Apr 12, 2010 10:53 pm
by JakeJ
I found this but I can't vouch for it. Give it a try.
http://www.phpwordlib.motion-bg.com/
Re: Word + PHP
Posted: Tue Apr 13, 2010 1:17 am
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.

Re: Word + PHP
Posted: Tue Apr 13, 2010 4:37 am
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
Re: Word + PHP
Posted: Tue Apr 13, 2010 7:29 am
by Petrini
Ok, thank you!
You all gave me some good ideas, and I'm gonna try everything I can

Re: Word + PHP
Posted: Tue Apr 13, 2010 3:29 pm
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