Php export method for generating word

Source: Internet
Author: User
Php export to generate the word method this article describes how to export and generate the word in php. We will share this with you for your reference. The details are as follows:

PHP export word

(1) first, preview the html page, sample object, and define the data to be exported.
(2) click the download page to pass a value to the id (any value can be used for determination only). if the id has a value, the output buffer file is saved as the word format.
(3) Click Download. (if an image is saved as a word, use the absolute path to display it normally in the saved word)
(4) Disable Cache output

Word_con.php preview the html file to be exported

 Start (); // define the start of the data to be saved} include ('Word _ show. php'); if (@ $ _ GET [id]! = '') {$ Word-> save('word_c.doc '); // defines the end of the data to be saved, at the same time, save the data to the word} if (@ $ _ GET [id] = '') {// The x in the hyperlink is only used to pass a value and confirm the download, no other actual yi?>

Click to jump to the download page

Word_fun.php export word-related functions

 ';} Function save ($ path) // defines the end of the data to be saved, and saves the data to word. // the data to be saved must be limited to start () of this class () and save () {print""; $ Data = ob_get_contents (); // return the internal buffer content to convert the output to the string ob_end_clean (); // end the output buffer, clean (erased) output Buffer and disable output buffer $ this-> wirtetoword ($ path, $ data);} function wirtetoword ($ fn, $ data) // save the data in binary format to word {$ fp = fopen ($ fn, "wb"); fwrite ($ fp, $ data ); fclose ($ fp) ;}}?>

Word_show.php connects to the database and queries related data

 

I hope this article will help you with PHP programming.

Related articles:

Php uses phpword to generate word documents

Generate a Word document on the web page in the php program and provide the downloaded instance code.

Three methods for generating word documents in PHP

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.