Convert html to word /excel / powerPoint with PHP

前端 未结 3 1861
感动是毒
感动是毒 2020-11-27 20:53

How to convert html to word /excel / powerpoint with PHP ?

相关标签:
3条回答
  • 2020-11-27 21:03

    Try the following PHP classes:

    • PhpSpreadsheet
    • PHPWord
    • PHPPresentation

    I only used PHPExcel so far but it worked great and is easy to learn. Since all classes are from the same company I assume that they should fit your needs as well.

    0 讨论(0)
  • 2020-11-27 21:09

    PHP to Word:

    I think the easiest way to generate DOC files with PHP is using the Zend Framework component phpLiveDocx. You can load Word or Open Office templates, merge textual data and save the final document to a number of formats, such as DOC, DOCX, RTF and PDF.

    0 讨论(0)
  • I agree that @Nick answer is correct, but you do not need an external tool to do what you need, at least not for Word.

    To generate a Word document simply add this code at the top of the page you want to convert.

    <?php 
       header("Content-Type: application/vnd.ms-word");
       header("Expires: 0");
       header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
       header("content-disposition: attachment;filename=MyReport.doc"); 
    ?>
    

    For Excel I found this (did not test):

    <?php
       header("Content-Type: application/vnd.ms-excel; charset=utf-8");
       header("Content-Disposition: attachment; filename=abc.xls");  
       header("Expires: 0");
       header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
       header("Cache-Control: private",false);
    ?>
    
    0 讨论(0)
提交回复
热议问题