Two ways to generate word in php tutorial
1. Create word with normal touch
2.fopen open word
3.fwrite write word and save
There will be a problem if the written thing contains html code, it will be written directly into word instead of typesetting
This problem requires adding a piece of code at the head of the output html code
$headert='
xmlns:w="urn:schemas-microsoft-com:office:word"For example, your content is $ text;
Then when writing $text=$header.$text.$footer;
In this way, the things in fck can be output according to the layout style!
Method 1
$word= new com("word.application") or die("unable to
create word document") ;
print "loaded word, version{$word->version}n";
$word->visible =0;
$word->documents->add();
//There is an error in setting the margin
// $word->selection->agesetup->rightmargin ='3"';
//Set the font
$word->selection->font->name ='helvetica';
//Set font size
$word->selection->font->size = 8 ;
//Set color
$word->selection->font->colorindex= 13; //wddarkred= 13
//Output to document
$word->selection->typetext("hello world ");
$range = $word->activedocument->range(0,0);
$table_t =$word-> activedocument->tables->add($range,3,4);
$table_t->cell(1,2)->range->insertafter('aaa');
/ /save
//$word->sections->add(1);
$word->documents[1]->saveas(dirname(__file__)."/create_test.doc") ;
//Exit
$word->quit();
?>
Method 2
class word
{
function start()
{
ob_start();
print'
Call method
$word=new word ;
$word->start();
echo $cout;
$wordname="word/".time().".doc";
$word->save( $wordname);//Save word and end