Need Help Exporting data to MS Word Form Fields from Linux

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
acidbox
Forum Newbie
Posts: 2
Joined: Fri Sep 06, 2002 5:05 pm

Need Help Exporting data to MS Word Form Fields from Linux

Post by acidbox »

I have been struggling with this issue for the past week with no avail. Let me explain what I am trying to accomplish.

Firstly, I am running linux server (Apache, PHP 4.1.1).

I spent all last week trying to get COM to work, and finally figured out that this only works on windows servers, (go figure).

Anyway, here is what I need to do.

1.) Open word
2.) Open Template file that includes form fields (.dot)
3.) Populate form with data passed from php script
4.) Save as a new file with a predetermined filename passed from the script.

If I could figure out how to accomplish those 4 tasks simulateously, it would be a miracle.

I somewhat figured out how to do steps 1 & 3 with this code that I modified from code that I found on sourceforge. Other than that I am completely lost.

The link for this code was posted in This Message.

Code: Select all

<?php
###########################################
## START - EXPORT CODE TO MICROSOFT WORD ##
###########################################
//note: if word file for dump desired, link to this page like:
//<a href='dump.php?w=1'>link</a>
//if this parameter is not included, file returned will be in excel format
if ($w==1)
	{
		$file_type = "msword";
		$file_ending = "doc";
	}
else
	{
		$file_type = "vnd.ms-excel";
		$file_ending = "xls";
	}

header("Content-Type: application/$file_type");
header("Content-Disposition: attachment; filename=" . $case_id . "-R.$file_ending");
header("Pragma: no-cache");
header("Expires: 0");

$sql = "SELECT * FROM cases WHERE case_id = '$case_id'";
$query = mysql_query($sql);
$i = 0;
while($row = mysql_fetch_row($query))
	{
                          echo(" data to export to word goes here");
	}
	
return (true);

###########################################
## END - EXPORT CODE TO MICROSOFT WORD   ##
###########################################
?>
Any help would be appreciated. I really don't know if this is possible or not.

Thanks again for any help!
Post Reply