Directly use php to create Word Document code (the system does not need to install wordsoftware)

Source: Internet
Author: User

Directly use php to create the word Document code (the system does not need to install the wordsoftware) usage: first use $ word-> start () to generate the word file. Then you can output any HTML code, whether it is read from the file and written here, or output HTML directly here.

Directly use the php tutorial to create the Word Document code (the system does not need to install the word software)
Usage:
Use $ word-> start () to generate a word file. Then you can output any html code, whether it is read from the file and written here, or output html directly here.
After the output is complete, use the $ word-> save ($ path) method. $ path is the name of the word file you want to generate (the complete path can be provided ). when you use the $ word-> save () method, any output after this is irrelevant to the word file, that is, the word generation is complete. And then pull it in the same way as you normally use php. Anything you output is directly output in the browser instead of written into the word.

*/

Class word
{

Function start ()
{
Ob_start ();
Print 'Xmlns: w = "urn: schemas-microsoft-com: office: word"
Xmlns = "http://www.w3.org/tr/rec-html40"> ';

}

Function save ($ path)
{

Print "$ Data = ob_get_contents ();

Ob_end_clean ();

$ This-> wirtefile ($ path, $ data );
}

Function wirtefile ($ fn, $ data)
{

$ Fp = fopen ($ fn, "wb ");
Fwrite ($ fp, $ data );
Fclose ($ fp );
}

}
// Generate a word call Method
Include ("word. php ");
$ Word = new word;
$ Word-> start ();


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.