Php 此HTML Word文档在OpenOffice.org中显示不正确
我用php编写了以下简单代码:Php 此HTML Word文档在OpenOffice.org中显示不正确,php,ms-word,openoffice.org,Php,Ms Word,Openoffice.org,我用php编写了以下简单代码: <?php header("Content-type: application/vnd.ms-word"); header("Content-Disposition: attachment;Filename=kid_tag.doc"); echo '<table cellspacing="0" cellpadding="0" border="0" width="8.4cm"> <tr> <td colspan
<?php
header("Content-type: application/vnd.ms-word");
header("Content-Disposition: attachment;Filename=kid_tag.doc");
echo '<table cellspacing="0" cellpadding="0" border="0" width="8.4cm">
<tr>
<td colspan="3" style="text-align: right; height: 0.6cm">Nursery</td>
</tr>
<tr>
<td style="height: 1.8cm"><img src="http://images.funadvice.com/photo/image/old/6943/tiny/cat.jpg" /></td>
<td style="text-align: center; font-weight: bold">Sofia Abello</td>
<td> </td>
</tr>
<tr>
<td style="text-align: left; height: 0.6cm">9AM Oct-12-08</td>
<td> </td>
<td style="text-align: right">Dance Studio</td>
</tr>
</table>';
?>
使用MS Office Word显示ok,但使用open Office writer打开时,宽度会减小(不是正确的宽度!) 您实际上是在将HTML导入MS Word和OpenOffice.org。HTML不是Word和OpenOffice.org的原生格式,这意味着必须首先转换输入 毫不奇怪,这些应用程序(其主要目的是以应用程序的原生格式编辑文档)在这方面做得并不完美。事实上——这并不是什么大秘密——甚至连主要用于呈现HTML的web浏览器都不是完美的 解决方案是提供在两种应用程序中都能工作的HTML。您可以使用它来实现这一点,它是Microsoft对HTML的专有扩展,因此只有Microsoft产品才能理解 在您的示例中,它可能是这样的:
<![if !mso]>
<table cellspacing="0" cellpadding="0" border="0" width="8.4cm">
<tr>
<td>OpenOffice.org Version</td>
</tr>
</table>
<![endif]>
<!--[if mso]>
<table cellspacing="0" cellpadding="0" border="0" width="8.4cm">
<tr>
<td>Microsoft Word version</td>
</tr>
</table>
<![endif]-->
OpenOffice.org版本
您实际上是在将HTML导入MS Word和OpenOffice.org。HTML不是Word和OpenOffice.org的原生格式,这意味着必须首先转换输入
毫不奇怪,这些应用程序(其主要目的是以应用程序的原生格式编辑文档)在这方面做得并不完美。事实上——这并不是什么大秘密——甚至连主要用于呈现HTML的web浏览器都不是完美的
解决方案是提供在两种应用程序中都能工作的HTML。您可以使用它来实现这一点,它是Microsoft对HTML的专有扩展,因此只有Microsoft产品才能理解
在您的示例中,它可能是这样的:
<![if !mso]>
<table cellspacing="0" cellpadding="0" border="0" width="8.4cm">
<tr>
<td>OpenOffice.org Version</td>
</tr>
</table>
<![endif]>
<!--[if mso]>
<table cellspacing="0" cellpadding="0" border="0" width="8.4cm">
<tr>
<td>Microsoft Word version</td>
</tr>
</table>
<![endif]-->
OpenOffice.org版本
我认为使用PHP生成文档文件的最简单方法是使用Zend Framework组件phpLiveDocx。您可以加载Word或打开Office模板,合并文本数据,并将最终文档保存为多种格式,如DOC、DOCX、RTF和PDF
在项目网站上了解更多信息:
我认为使用PHP生成文档文件的最简单方法是使用Zend Framework组件phpLiveDocx。您可以加载Word或打开Office模板,合并文本数据,并将最终文档保存为多种格式,如DOC、DOCX、RTF和PDF 在项目网站上了解更多信息: