-2
我能够生成Microsoft Word文件,但我想要表格结构中的数据。我在PHP中使用了一个HTML表格标签,但输出看起来并不令人满意。在表中有很多cellpacing和cellpadding,即使我已经将它们初始化为零空间。任何想法如何解决这个问题?在PHP中生成Microsoft Word文件
在这里不用我的代码
header("Content-type: application/vnd.ms-word");
header("Content-Disposition: attachment;Filename=document_name.doc");
$now_date = date('d-m-Y H:i');
echo "<html>";
echo "<body>";
echo "</body>";
echo "<head>";
echo "<div>Seminarthema:</div>\n";
echo "<div>Termin:$now_date</div>";
echo "<br></br>";
echo "<div style='size:20px;'><h2>Teilnehmerliste</h2></div>";
echo "<table border='1' cellpadding='0' cellspacing='0'>
<tr><th>Name</th><th>Vorname</th><th>Buchungskreis</th><th>Kurs-ID</th><th>Teilgenommen</th></tr>";
$students = $GLOBALS["TYPO3_DB"]->exec_SELECTquery('*','tx_training_Registration','hidden=0 AND deleted=0');
$countstud = $GLOBALS['TYPO3_DB']->sql_num_rows($students);
if($countstud){
while($row2 = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($students)){
echo "<tr>";
echo "<td>".utf8_decode($row2['firstname'])."</td>";
echo "<td>".utf8_decode($row2['lastname'])."</td>";
echo "<td>".utf8_decode($row2['companycode'])."</td>";
echo "<td>".utf8_decode($row2['trainingid'])."</td>";
echo "<td>".utf8_decode($row2[' status'])."</td>";
echo "</tr>";
}
}
echo "</table>";
echo "</head>";
echo "</html>";
该文件的用途是什么?用*空格*表示屏幕上的内存或空间吗?也许CSV会更好。 (我假设你只是生成一个包含单词的文件;)) – 2011-01-22 10:06:53
也许你应该通过解释你想要做什么,用完整的单词(O/P =?),完整的句子和适当的术语来阐述你的问题(我们是假设“Word”实际上是微软的Word?) – thkala 2011-01-22 10:07:30