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'> ".$ii." </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;
}
?>