Page 1 of 1

COM vs XML vs RTF vs ?

Posted: Tue Apr 08, 2003 12:05 am
by rxsid
Hi All,

I'm looking for the best way to generate a formated report (data from MySQL DB, no images) that will ultimately be sent via email. (So generating output to just browser won't due).

I've hear & read a lot about using COM to create .doc documents, but I've yet to see (or develop myself), working code to do so. I am using php 4.3.3 on an NT4 box using IIS.

What about XML to format a report, then send it via php's mail ()?

Or, anything out there for RTF?

Any additional input on this would be greatly appreciated.

Thanks.

Posted: Tue Apr 08, 2003 1:16 am
by llimllib
I believe that there are modules for working with RTF, although I couldn't link to them and I'm not sure; I'd google for it. Also, there are solid PHP modules for working with PDF, which might be more cross-platform than .doc files would be. Also, as a moral thing, I never make .doc files, but you probably don't share that bias.

Posted: Tue Apr 08, 2003 4:27 am
by pootergeist
as llimllib stated, using a proprietary format such as .doc isn't as useful as it sounds - even on my M$ station I don't run word so would have to open a .doc in wordpad thus destroying much of the formatting. Obviously anyone on *nix would be very unlikely to bother trying to open the file at all. You'd also get a few paranoid types who would stay clear fearing a virus lurking in the style macro.

pdf - though it requires a third party software reader is a lot more portable - a very high percentage of people can open and view pdf documents. there are quite a few extras you can do with php generated pdf files, including password protecting them.

xml is a tricky one as the basic file format doesn't really do anything, it just structures the data nicely. clicking the file would display vaguely in IE in an unstylized fashion. slinging along an xslt to do the styling would probably be asking a tad much from your recipients.

you could though - format a bob standard .html page and send that, as anyone surfing the web can view html without having to install any new software. plus, the html format is probably one you are already familiar with and your recipients are comfortable with.

so... my votes are either pdf or html

Posted: Tue Apr 08, 2003 11:03 am
by bznutz
There is a library in PHP that allows you to create and work with COM objects. All you have to do is learn how to manipulate that library to create and interface with a COM object. Then you must learn the functions of the COM object.

What I've always done when working with Office COM from the server side is open the application and record a macro of you formatting a document the way you want your script to format the doc. Then once the macro is recorded, open it in the VBA editor. You will then see the VBA code that accomplishes the formatting you want. In Active Server Pages all you have to do is cut and paste the VBA into the .asp script and you're golden. In PHP it will be a bit harder because you have to mate the PHP COM interface functions with the VBA that operates the COM object functions.

This all really isn't as difficult as it sounds. It may take some simple fiddling with the code.

word

Posted: Mon Feb 16, 2004 12:43 pm
by Burrito
I found a way to invoke a word instance using com to dynamically create word documents. But I'm struggling with being able to keep the instance of Word open on the server so that it doesn't require the server to invoke a new instance every time I try to generate a document.

Wondering if you ever found a solution to this. I'm more than happy to provide what I've got for you.

If you did ever find a solution to this, were you able to keep the instance of Word open?

thx,

Burr