php无法写入word文档,PHP生成WORD文档的问题
通過網頁編輯相關數據庫,自動生成一個WORD文件,供文件管理存檔或發送給別人使用的問題,如何解決?
$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();
//設置邊距
$word->Selection->pageSetup->LeftMargin = '3';
$word->Selection->pageSetup->RightMargin = '3';
//設置字體
$word->Selection->Font->Name = 'Helvetica';
//設置字號
$word->Selection->Font->Size = 8;
//設置顏色
$word->Selection->Font->ColorIndex= 13; //wdDarkRed =
13
//輸出到文檔
$word->Selection->TypeText("string string string string
string string ");
$range = $word->ActiveDocument->Range(0, 0);
$table_t =
$word->ActiveDocument->Tables->Add($range,3,4);
$table_t->Cell(1, 2)->Range->InsertAfter('aaa');
//保存
//$word->Sections->Add(1);
$word->Documents[1]->SaveAs(dirname(__FILE__)."/create_test.doc");
//退出
$word->quit();
?>
總結
以上是生活随笔為你收集整理的php无法写入word文档,PHP生成WORD文档的问题的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: php 当我添加数据成功后跳到首页 为什
- 下一篇: 营收创6年最大跌幅!苹果被曝裁员外包员工