Create Word document code directly with PHP (System does not need to install Word software) _php tutorial

Source: Internet
Author: User
Create Word document code directly with PHP (the system does not need to install the word software): First, use $word->start () to indicate that you want to build the Word file. Then you can output any HTML code, whether it is read from the file and then written here, or directly here to output HTML, there is no relationship.

Create Word document code directly with PHP tutorial (System does not need to install Word software)
How to use:
First, use $word->start () to indicate that you want to generate a Word file. Then you can output any HTML code, whether it is read from the file and then written here, or directly here to output HTML, there is no relationship.
When you are finished, use the $word->save ($path) method, where $path is the name of the word file that you want to generate (you can give the full path). When you use the $word->save () method, Any output after this is not related to the Word file, which means that word generation is complete. You can then pull the same way you would normally use PHP. Whatever you export, output directly in the browser, but not in 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 Word Call method
Include ("word.php");
$word =new Word;
$word->start ();


http://www.bkjia.com/PHPjc/444887.html www.bkjia.com true http://www.bkjia.com/PHPjc/444887.html techarticle Create Word document code directly with PHP (the system does not need to install the word software): First, use $word->start () to indicate that you want to build the Word file. Then you can output any HTML code, regardless of ...

  • Related Article

    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.