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 ();