Word/Excel file generation

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

Is it possible to generate word/excel files in PHP ? with a template  
file ?...

It is possible in Java so I guess it is possible in PHP to. I allready  
know how to do PDF...

Can anyone help me ?

Thx. Titi

Re: Word/Excel file generation

Thierry wrote:

Quoted text here. Click to load it

Hi Titi,

Yeas, some API's have been written in the past, but they always suffer from  
the fact that M$ is changing their format in their newer versions.

I think the safest bet for you is to use Word and Excel themself on a W$  
machine as server.
The process in short:
1) Instantiate a new Word-object. (Let PHP do that)
2) Do stuff on that object, like opening a template, etc. etc.
3) Safe a copy somewhere, or stream the copy to a client.
4) close and destroy the object.

The above approach used to be suspect for memoryleaks.
I am unsure how things are now on moderen OS's from M$.

The process is refered to as 'automation' I think.
Google for it for hints and examples.

You can also find many examples on the net, most are written in VBScript,  
but do not let that demotivate you: You can use the same api once you  
create an object in PHP, since the underlying object (and methods) are the  

Good luck.

Erwin Moller

Re: Word/Excel file generation

Kimmo Laine wrote:
Quoted text here. Click to load it

Unless next_page.php generates PHP, the script with this include will
only get HTML.

Quoted text here. Click to load it


    if (isset($_GET['foo'])) {
      echo '<?php echo $_GET[\'foo\']; ?>';
    } else {
      echo '<?php echo \'Not available\'; ?>';

File not found: (R)esume, (R)etry, (R)erun, (R)eturn, (R)eboot

Re: Word/Excel file generation

Create text files that are tab or comma separated for easy loading into

For WORD create an RTF file if you want all the formatting. Google it,
there are some sites out there that explain how. Easiest to create your
own template file (have a look at it in a plain text editor or in
emacs) and then insert the new text in the middle following the RTF
formatting rules. Yes, I have done this a few times. Not too hard once
you get the hang of it.


Re: Word/Excel file generation

MsKitty wrote:
Quoted text here. Click to load it

Well if you have website examples...


Site Timeline