开发者

Generating docx files with php using PHPDOCX

I guess no one was lucky to found the best solution of handling reports in php, specialy when it's a .doc/x report or file .... i searched for sometime and then i found phpdocx.com .. amazing php script, but it just doesn't work, and i don't know exactly where to find the output file ... and unfortunately the documentation doesn't help at any level ...

Now i need to know the way this script work .. i mean how results come out and become usable ... and what needs it take the script to work .. because it simply doesn't work on my local host .. i am using appache 2, php 5.2.6 ..

I don't actually need more than writing html with in ( a real doc format file, not rename a html file to 开发者_如何学编程.doc !! ), so if there is any solution ( without the COM Lib ... i am not on a windows server ) to generate real doc file with HTML .. please but it here

Thanks very much in advance :)


I guess no one was lucky to found the best solution of handling reports in php, specialy when it's a .doc/x report or file

This is not the question corresponding to the title, but you should try OpenTBS.

It's an open source PHP library which builds DOCX with the technique of templates.

No temp directory, no extra exe needed. First create your DOCX, XLSX, PPTX with Ms Office, (ODT, ODS, ODP are also supported, that's OpenOffice files). Then you use OpenTBS to load the template and change the content using the Template Engine (easy, see the demo). At the end, you save the result where you need. It can be a new file, a download flow, a PHP binary string.

OpenTBS can also change pictures and charts in a document.

  • Demo page
  • Documentation


The documentation of PHPDocX has been greatly improved. Have you tried to look at the PHPDocX tutorial? You may also have a look at the Forum.


require_once "Path of phpdocx library/CreateDocx.inc";

$docx = new CreateDocx();

$html = 'your data will store in this variable';
$docx->embedHTML(
    $html,
    array(
        'parseDivsAsPs' => true,
        'downloadImages' => true,
        'WordStyles' => array(
            '<table>' => 'MediumGrid3-accent5PHPDOCX'
        ),
        'tableStyle' => 'NormalTablePHPDOCX'
    )
);

$docx->createDocx($varPublicPath.'/word_export_file/example1_'.time());
// this is location where your docx file will generate(inside word_export_file docx file will store)
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜