Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 将html转换为文档时填充无效_Php_Html_Ms Word_Doc - Fatal编程技术网

Php 将html转换为文档时填充无效

Php 将html转换为文档时填充无效,php,html,ms-word,doc,Php,Html,Ms Word,Doc,我正在使用以下代码将html转换为文档 <?php header("Cache-Control: ");// leave blank to avoid IE errors header("Pragma: ");// leave blank to avoid IE errors header('Content-type: application/vnd.openxmlformats-officedocument.wordprocessingml.document'); header('Con

我正在使用以下代码将html转换为文档

<?php
header("Cache-Control: ");// leave blank to avoid IE errors
header("Pragma: ");// leave blank to avoid IE errors
header('Content-type: application/vnd.openxmlformats-officedocument.wordprocessingml.document');
header('Content-Disposition: attachment; filename="'.$filename.'.doc"');
?>
<html xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:w="urn:schemas-microsoft-com:office:word"
xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=utf-8">
<meta name=ProgId content=Word.Document>
<meta name=Generator content="Microsoft Word 12">
<meta name=Originator content="Microsoft Word 12">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]-->
<!--[if gte mso 9]><xml>
 <w:WordDocument>
  <w:View>Print</w:View>
  <w:DoNotHyphenateCaps/>
  <w:PunctuationKerning/>

 </w:WordDocument>
</xml><![endif]-->
</head>
<body>
<div style="padding:20px;border:1px solid black;">test data</div>
</body>
</html>

在输出文档文件中,div没有填充和边框。但如果我使用table而不是div,它就会工作。所以,请建议我任何其他方式,以便我可以在div中提供填充和边框。这个问题不是因为内联css。其他css正在工作

MS以神秘的方式工作。尝试为div元素指定一个类,并为该类指定一个样式。像and.padding20{padding:20px;}我也尝试了这个,但没有找到结果@奥勒豪斯特酒店