欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程语言 > php >内容正文

php

php无法写入word文档,PHP生成WORD文档的问题

发布时间:2023/12/15 php 41 豆豆
生活随笔 收集整理的这篇文章主要介绍了 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文档的问题的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。