开发者

How to create a MsWord (.doc) file from php that spans more than one page (using html)

开发者 https://www.devze.com 2023-01-09 05:17 出处:网络
i need to create a .doc file that has more than one page. I want to create the doc file from html (setting the headers so that it is interpreted as a doc file) but i don\'t know how to add a page brea

i need to create a .doc file that has more than one page. I want to create the doc file from html (setting the headers so that it is interpreted as a doc file) but i don't know how to add a page break in html that is correctly recognized from word.

Thanx in adv开发者_开发问答ance


You may find PHPWord to be useful.

PHPWord is a library written in PHP that create word documents.

Update:

Method One:

Here is a method using COM (requires Word to be installed)

Method Two:

Use appropriate headers, here is an example:

header("Content-type: application/vnd.ms-word");
header("Content-Disposition: attachment;Filename=document_name.doc");

echo "<html>";
echo "<body>";
echo "<b>My first document</b>";
echo "</body>";
echo "</html>";
0

精彩评论

暂无评论...
验证码 换一张
取 消