【发布时间】:2011-12-18 17:07:03
【问题描述】:
我有一个像下面这样的html格式的srting
<?xml version="1.0" encoding="utf-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"><head><style><!--
/*paged media */ div.header {display: none }
div.footer {display: none } /*@media print { */
@page { size: A4; margin: 10%; @top-center {
content: element(header) } @bottom-center {
content: element(footer) } }
/*font definitions*/
/*element styles*/ .del
{text-decoration:line-through;color:red;}
.ins {text-decoration:none;background:#c0ffc0;padding:1px;}
/* Word style definitions */
/* TABLE STYLES */
/* PARAGRAPH STYLES */
.DocDefaults {display:block;space-after: 4mm;line-height: 115%;font-family: Calibri;font-size: 11.0pt;}
.Normal {display:block;}
/* CHARACTER STYLES */ .DefaultParagraphFont {display:inline;}
/* TABLE CELL STYLES */
--></style><script type="text/javascript">
function toggleDiv(divid){
if(document.getElementById(divid).style.display == 'none'){
document.getElementById(divid).style.display = 'block';
}else{
document.getElementById(divid).style.display = 'none';
}
}
</script></head><body>
<!-- userBodyTop goes here -->
<div class="document">
<p class="Normal DocDefaults "><span style="font-weight: bold;">Hi</span><span style="white-space:pre-wrap;"> </span>[name]<span style="white-space:pre-wrap;">. </span><span style="font-weight: bold;color: #FF0000;">your</span><span style="white-space:pre-wrap;"> ac is</span><span style="white-space:pre-wrap;"> </span>[acc_no]<span style="white-space:pre-wrap;">, and </span><span style="font-weight: bold;color: #FF0000;">your</span><span style="white-space:pre-wrap;"> password </span><span style="white-space:pre-wrap;">is </span>[password].</p>
<p class="Normal DocDefaults ">Thanks you.</p></div>
<!-- userBodyTail goes here -->
</body></html>
我想使用这个字符串制作一个 .doc 或 .docx 文件。 doc或docx应该保存在目录和数据库中的链接以供下载。怎么办?
【问题讨论】:
-
你有没有尝试过?你也见过phpdocx.com吗?
-
phpdocx 需要服务器中的 pdf 和 zip 模块。但我无法安装这些模块。所以我正在寻找核心 php 代码。上面的字符串可以导出为文档,用户可以保存。但我的要求是将其保存在服务器目录中并将目录链接到数据库以供以后下载
-
当我在浏览器中显示 html(文档另存为网页)时,文档的样式会正确显示。当我再次将其导出到 doc 时,样式显示不正确。有什么问题?