PHP Read and Write in MS WORD

前端 未结 5 990
伪装坚强ぢ
伪装坚强ぢ 2020-12-11 12:31

I want to read/write word documents using PHP,

I know there is a function in php to work with COM objects which we can use to read and write word documents, but COM

5条回答
  •  猫巷女王i
    2020-12-11 12:57

    Create / Write a MS RTF Word Document by using this pure PHP Code

    Use this free Lib: https://github.com/phprtflite/PHPRtfLite

    Works on Windows, Linux and Mac OS

    Take a look at the Documentation over here: http://sigma-scripts.de/phprtflite/docs/

    Also read this if you what to now more about Office File Formats:

    https://joelonsoftware.com/2008/02/19/why-are-the-microsoft-office-file-formats-so-complicated-and-some-workarounds/

     Text 
    Text
    Text

    This is Lorem Ipsum Dolore Text. This is Lorem Ipsum Dolore Text. This is Lorem Ipsum Dolore Text. This is Lorem Ipsum Dolore Text. This is just another paragraph. '; // TAGS THAT WILL WORK: ,
    , , , , and // SET VAR $dir = dirname(__FILE__); // PHPRtfLite require_once $dir . '/PHPRtfLite/lib/PHPRtfLite.php'; PHPRtfLite::registerAutoloader(); $rtf = new PHPRtfLite(); $sect = $rtf->addSection(); // ADD CONTENT AS HTML // 'Arial' 'Verdana' 'Tahoma' Times New Roman' etc. // TEXT_ALIGN_LEFT, TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER, TEXT_ALIGN_JUSTIFY $sect->writeText( $headline, new PHPRtfLite_Font(24, 'Arial'), new PHPRtfLite_ParFormat(PHPRtfLite_ParFormat::TEXT_ALIGN_CENTER) ); $sect->writeText( $content, new PHPRtfLite_Font(12, 'Arial'), new PHPRtfLite_ParFormat(PHPRtfLite_ParFormat::TEXT_ALIGN_LEFT) ); // SAVE RTF DOCUMENT $rtf->save($dir . '/' . basename(__FILE__, '.php') . '.rtf');

提交回复
热议问题