Home>Article>PHP Framework> How to export word with thinkphp
thinkphp needs to introduce the Wordmaker.class.php class file to export word, and use this class file to generate and export the word document. The following describes the implementation process:
Create a new WordController.class.php file in the controller folder of Thinkphp as a controller for generating word.
Put the Wordmaker.class.php class file under the Util folder of the Thinkphp directory for the following steps to import it using the import method class file.
Related recommendations: "ThinkPHP Tutorial"
Create a new WordMake method in the wordController controller to generate word documents. In the WordMake method, you need to load the Wordmaker.class.php class file first. The code is as follows:
#Write code in the WordMake method to convert html content into word document content. The code is as follows:
#Write code and use the WordMake method to generate a word document. Create a new execution method outword() for exporting word documents.
Get the content of the word document to be generated in the outword() method (for the convenience of testing, a piece of HTML code is used here and saved in the $content variable), through WordMake The method generates a word document and saves it in the root directory with the document name "Test". The code is as follows:
#Run the code in the browser and view the generated word document.
By viewing the content of the word document, it can be seen that the red text "
The above is the detailed content of How to export word with thinkphp. For more information, please follow other related articles on the PHP Chinese website!