This topic is locked

Modifying template for word export

10/27/2006 8:15:12 PM
PHPRunner General questions
G
gdude66 author

Hi,

I can't find an answer in the forums but if I have a set of fields that I want to export to a word document using the word export - where can I modify the word template so that it sticks the field values in the appropriate places with text all around it?
eg a standard letter which pulls the fields from phprunner such as address, name, amount etc

R
RickG 10/28/2006

Is this for a "single" record export? Or are you exporting multiple records? If the latter, would it not be easier to 1) export to a csv file and 2) initiating a mail merge into a Word doc?

T
thesofa 10/28/2006

Is this for a "single" record export? Or are you exporting multiple records? If the latter, would it not be easier to 1) export to a csv file and 2) initiating a mail merge into a Word doc?



I agree, this will free up the database for continued use, rather than tying it up printing 1400 letters from the database?

Failing that, I think you may be forced to accept HTML formatting.

G
gdude66 author 10/28/2006

This is for a single letter with fields inserted - ie export on update for a single record.

Alexey admin 10/30/2006

Graeme,
I recommend you to create your letter in Word then add some PHP code to it.
Create a letter putting some easy to find patterns in place of real values to be selected from database.

I.e. AAAAAAA instead of address and so on.

Save your letter as RTF.
Rename it to php and open in plain-text editor.

Put some code into beginning to select values from database and to tell the browser that the file is RTF.

Here is the code to identify file as RTF:

header("Content-Disposition: attachment; Filename=Letter.rtf");

header("Content-Type: text/rtf");


Then find all your patterns and replace them with PHP code snippets.

I.e. find AAAAAAA and replace it with:

<?php echo $address; ?>

G
gdude66 author 10/30/2006

Thanks Alexy - will give i a try