PHP Classes

create document

Recommend this page to a friend!

      Top level forums  >  PHP Specialists  >  General  >  create document  
Subject:create document
Summary:write vertical into a table, not in browser, but a file
Messages:3
Author:kogan sheina
Date:2009-01-28 18:09:11
Update:2009-02-03 02:48:50
 

  1. create document   Reply   Report abuse  
Picture of kogan sheina kogan sheina - 2009-01-28 18:40:53
I generate an word document from a SQL database. There are fields (table cells) which are not wide enough to contain the text. I use
writing-mode:tb-rl option to write it vertically. The table is rendered correctly in browser, but still put the text horizontal when it goes to a file.

Follow my example :

the writing-mode:tb-rl works fine in any browser, but writes horizontally into a file


<?php
$path = "c:\\";
$file = openDocument("test",$path);
writeDocument($file, "<table border=3 cellpadding=0 cellspacing=0 >");
writeDocument($file, "<tr>");
writeDocument($file, "<td style = 'font-size :10pt;height :20pt;font-weight:bold;background-color :DarkGray' colspan=2>Bit</td>");
for ($i=31; $i>=0; $i--)
{
if ( $i <=9 ) $ii = '0'.$i;
else $ii = $i;
writeDocument($file, "<td width=3% style = 'font-size :10pt;height :20pt'>&nbsp;".$ii."&nbsp;</td>");
}
writeDocument($file, "</tr>");

writeDocument($file, "<tr>");
writeDocument($file, "<td style='font-size :10pt;height :20pt; font-weight:bold;background-color :DarkGray' colspan = 2>Field</td>");
writeDocument($file, "<td style='font-size :10pt;height :20pt' align= middle valign=middle colspan = 13>R3</td>");
//
writeDocument($file, "<td style='font-size :10pt;height :20pt; writing-mode:tb-rl' align= middle valign=middle>DISCARD</td>");
writeDocument($file, "<td style='font-size :10pt;height :20pt; writing-mode:tb-rl' align= middle valign=middle>FLOW31MASK</td>");
writeDocument($file, "<td style='font-size :10pt;height :20pt; writing-mode:tb-rl' align= middle valign=middle>BUFSIZE</td>");
writeDocument($file, "<td style='font-size :10pt;height :20pt' align= middle valign=middle colspan = 3>R2</td>");
writeDocument($file, "<td style='font-size :10pt;height :20pt' align= middle valign=middle colspan = 5>THREAD</td>");
writeDocument($file, "<td style='font-size :10pt;height :20pt' align= middle valign=middle >R1</td>");
writeDocument($file, "<td style='font-size :10pt;height :20pt' align= middle valign=middle colspan = 7>ROUTE</td>");
//
writeDocument($file, "</tr>");
writeDocument($file, "</table>");
closeDocument($file);

function openDocument($gchip,$path)
{
if ( $path != "" )
{
$f = $path.$gchip.'.doc';
$file = fopen($f, 'w+');
return $file;
}
return false;
}
function closeDocument($file)
{
if ($file) fclose($file);
}
function writeDocument($file, $data)
{
if ($file) fwrite($file, $data);
else echo $data;
}

?>


There are 2 replies in this thread, which are not being displayed.
Browsing this forum thread replies is available only to premium subscribers.


Go to the premium subscriptions page to learn how to become a premium subscriber and have full access to this forum.