This article mainly introduces the method that PHP exports word, the interested friend's reference, hoped to be helpful to everybody.
PHP Export Word
(1) First, preview the HTML page, instantiate the object, define the data to be exported
(2) Click on the download page, give the ID value (any value can be used only to determine), if the ID has a value, output buffer file, saved in Word format.
(3) After clicking on the download, (if it is a picture, use absolute path when saving as word, so that it can be displayed normally in saved word)
(4) Turn off cache output
word_con.php previewing the HTML file to export
<?phpif (@$_get[id]!= ") {include (' word_fun.php '); $word =new Word ();//Sample Object $word->start ();//define the beginning of the data to be saved} Include (' word_show.php '); if (@$_get[id]!= ') { $word->save (' Word_c.doc ');//define the end of the data to be saved and save the data to Word} if (@$_get[id]== ") {// The x in the hyperlink is just to pass a value, confirm the download, no other actual Yi?> <a href= "#" ><p onclick= "window.location.href= ' word_con.php?id=x '" > Click to skip to download page </p></a> <?php}else{echo "<a href=\" word_c.doc\ "> Download </a>";}? >
word_fun.php exporting Word related functions
<?phpclass word{function Start ()//define the beginning of the data to be saved { ob_start ();//Start output buffer //set to generate Word format print '
word_show.php connection database, query related data
<?php include (' conn.php ');//Connect Database $sq = "Select Zf_content from ZF where ' zf_id ' =137"; $sql =mysql_query ($SQ); while (($que =mysql_fetch_array ($sql))!=false) { echo "<font color=\" red\ ">hahaahahha</font>"; echo $que [' zf_content ']; }?>
Summary : The above is the entire content of this article, I hope to be able to help you learn.
Related recommendations:
How to use PHP to implement URLs in a regular crawl page
The calculation method of ID card check code based on PHP
PHP implementation of four basic sorting algorithm run time comparison (must read)