|
Posted by Justin on 12/05/06 03:56
Thanx all of ya.... Btw, NC, im trying out on ur solutions... hopefully
can get it done... im using a linux server... so the generating rtf
files surely is a much more attractive solution... =>
NC wrote:
> Justin wrote:
> >
> > i found the solution to export file from mysql db into *.csv.
> > but is there anyway to convert the contents into *.doc and
> > save in my webserver and providing a link for the end users
> > to download the word file?
>
> Yes. You need a dedicated Windows server with Word installed
> on it. You would retrieve records from the database and convert
> them into Word documents by calling Word as a COM object.
> The disadvantage of this approach is that it's expensive, both
> in terms of system resources utiltized and in terms of direct
> monetary costs (dedicated Windows servers are not particularly
> cheap).
>
> A much more attractive alternative is to generate RTF (Rich Text
> Format) files. Word understands them just fine, as do most of
> other modern word processors. Here's a simple example.
>
> Create an empty document in Word and type:
>
> First Name: ###First_Name###
> Last Name: ###Last_Name###
>
> Then save this document as a Rich Text Format (RTF) file.
> Let's call it app.rtf. Put this file on your server next to your
> script. Now you can do this:
>
> <?php // be sure this is the first line of the script file
>
> $first = 'John';
> $last = 'Doe';
> $rtf = file_get_contents('app.rtf');
> $rtf = str_replace('###First_Name###', $first, $rtf);
> $rtf = str_replace('###Last_Name###', $last, $rtf);
> header ('Content-type: application/msword');
> // alternatively, you may try
> // header ('Content-type: application/rtf');
> header ('Content-Disposition: inline; filename: jobapp.rtf');
> echo $rtf;
> die ();
>
> ?>
>
> And the user will see a Word document that says:
>
> First Name: John
> Last Name: Doe
>
> This is a very simple example, but you can make it as complicated
> as you want, with as many placeholders as you need. In your case,
> you will need to draw $first and $last from the database.
>
> Cheers,
> NC
Navigation:
[Reply to this message]
|