Deep Tech Fusion

tech related weblog

Update Word document through PHP

$filename = “C:\\document_”.date(“YmdHis”).”.doc”;

$template = “C:\\template.htm”;

$fp_temp = fopen($template, “rb”);
$fp = fopen($filename, “wb”);

$old_contents = fread ( $fp_temp, filesize ($template));
fclose ( $fp_temp);
$new_constants = str_replace(“var_username”, “Deepak”, $old_contents);

$rset = “<table width=’100%’ ><tr><td>#</td><td >Name</td><td >Date of Join</td><td >Title</td><td >Dept</td></tr>”;
$rset .= “<tr><td>123</td><td>Deepak</td><td>Oct 10, 2003</td><td>Programmer</td><td>IT</td></tr>”;
$rset .= “<tr><td>123</td><td>Sachin</td><td>Oct 10, 2005</td><td>Developer</td><td>IT</td></tr>”;
$rset .= “<tr><td>123</td><td>Amita</td><td>Oct 10, 2006</td><td>System Admin</td><td>HR & Admin</td></tr>”;
$rset .= “<tr><td>123</td><td>Deepa</td><td>Oct 10, 2002</td><td>Hr Head</td><td>HR & Admin</td></tr>”;
$rset .= “<tr><td>123</td><td>Poja</td><td>Oct 10, 2003</td><td>Developer</td><td>IT</td></tr></table>”;
$constants = str_replace(“Var_record_sets”, $rset, $new_constants);

fwrite($fp, $constants) ;

Advertisements

December 28, 2006 - Posted by | PHP

No comments yet.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: