sheinak Posted December 24, 2008 Share Posted December 24, 2008 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. put $path = "" and you have on browser 2 rows of a table, nice put $path = "c:\" or any legal file path you will receive a file named test.doc into the set location. The table is not so nice. <html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <!--meta http-equiv="Content-type" content="text/html;charset=Windows-1252" /--> <meta http-equiv="Content-type" content="text/html;charset=utf-8" /> </head> <body> <?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; } ?> Quote Link to comment Share on other sites More sharing options...
btherl Posted January 4, 2009 Share Posted January 4, 2009 What exactly do you want? Do you want it to display in the file the way it does in a browser? Quote Link to comment Share on other sites More sharing options...
sheinak Posted January 10, 2009 Author Share Posted January 10, 2009 yes, please !! I want to receive a document as the browser draw it. I have all, besides the vertical text. thank you Quote Link to comment Share on other sites More sharing options...
btherl Posted January 11, 2009 Share Posted January 11, 2009 Are you writing the exact same contents to the file as you do to the browser? Perhaps you should try giving the file the ".html" extension instead, which will have it rendered in a browser when someone opens it. Quote Link to comment Share on other sites More sharing options...
sheinak Posted January 11, 2009 Author Share Posted January 11, 2009 I do write to the file as in browser: function writeDocument($file, $data) { if ($file) fwrite($file, $data); else echo $data; } if $file is a file descriptor it will write to file otherwise it will echo to the browser I need to be a MS word document Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.