我知道thinkphp怎样导入单个第三方php class,但不知道如何导入phpword(里面有

2024-05-18 22:07

1. 我知道thinkphp怎样导入单个第三方php class,但不知道如何导入phpword(里面有

直接把第三方的类库放到指定类库用import导入,或者放到根目录下也可以,真有味一个文件夹,导入主要的PHP文件即可

我知道thinkphp怎样导入单个第三方php class,但不知道如何导入phpword(里面有

2. thinkphp怎么生成word

PHP操作Word文档的方法有很多,这里为大家提供一种高效方法,要比服务器安装com组件效率高的多,因为 word的com组件还要打开客户端。
首先保证你的服务器安装Microsoft Office
本文以下载素材火的特效页面,作为word输出内容。当然你也可以自定义字符串内容,比如表格、列表、标题等。
若是有图片的话,咱们必须转换成mht格式。
PHP生成word,并即时下载代码:
$url = file_get_contents("http://www.sucaihuo.com/js"); 
$fileContent = getWordDocument($url); 
$fileName = iconv("utf-8", "GBK", '素材火' . '_' . $id . '_' . rand(100, 999)); 
header("Content-Type: application/doc"); 
header("Content-Disposition: attachment; filename=" . $fileName . ".doc"); 
echo $fileContent;

3. 用thinkPHP上传一份word文件,怎样显示出来

<?php
/*
* 必须将 php.ini 中的 com.allow_dcom 设为 TRUE
*/

function php_Word($wordname,$htmlname,$content)
{
//获取链接地址
$url = $_SERVER['HTTP_HOST'];
$url = ";
$url = $url.$_SERVER['PHP_SELF'];
$url = dirname($url)."/";
//建立一个指向新COM组件的索引
$word = new COM("word.application") or die("Unable to instanciate Word");

//显示目前正在使用的Word的版本号
echo "Loading Word, v. {$word->Version}";

//把它的可见性设置为0(假),如果要使它在最前端打开,使用1(真)
$word->Visible = 1;
//---------------------------------读取Word内容操作 START-----------------------------------------
//打开一个word文档
$word->Documents->Open($url.$wordname);

//将filename.doc转换为html格式,并保存为html文件
$word->Documents[1]->SaveAs(dirname(__FILE__)."/".$htmlname,8);

//获取htm文件内容并输出到页面 (文本的样式不会丢失)
$content = file_get_contents($url.$htmlname);
echo $content;

//获取word文档内容并输出到页面(文本的原样式已丢失)
$content= $word->ActiveDocument->content->Text;
echo $content;

//关闭与COM组件之间的连接
$word->Documents->close(true);
$word->Quit();
$word = null;
unset($word);
//---------------------------------新建立Word文档操作 START--------------------------------------
//建立一个空的word文档
$word->Documents->Add();

//写入内容到新建word
$word->Selection->TypeText("$content");

//保存新建的word文档
$word->Documents[1]->SaveAs(dirname(__FILE__)."/".$wordname);

//关闭与COM组件之间的连接
$word->Quit();
}
php_Word("tesw.doc","filename.html","写入word的内容");
?>

用thinkPHP上传一份word文件,怎样显示出来

4. thinkPHP5.0怎么在生成的word中加入图片

如果使用的是phpword插件操作word 可以看下这篇

5. thinkphp 生成word

直接将 html生成word就行了 部分代码
//导出wordecho 'Print ';$this->display($tpl);;echo '';$wordname = $title;ob_start(); //打开缓冲区Header("Cache-Control: public");Header("Content-type: application/octet-stream");Header("Accept-Ranges: bytes");if (strpos($_SERVER["HTTP_USER_AGENT"],'MSIE')) {    Header("Content-Disposition: attachment; filename=$wordname.doc");}else if (strpos($_SERVER["HTTP_USER_AGENT"],'Firefox')) {    Header("Content-Disposition: attachment; filename=$wordname.doc");} else {    Header("Content-Disposition: attachment; filename=$wordname.doc");}Header("Pragma:no-cache");Header("Expires:0");ob_end_flush();//输出全部内容到浏览器

thinkphp 生成word

6. thinkphp如何读取word文档???

可以的,PHP本身就有打开文件函数和读取函数,其实Word文档不也是文本吗,可以当做txt来读的

7. thinkphp 在新页面输出转换成word文档的问题

Version} ”; // 把它的可见性设置为0(假),
如果要使它在最前端打开,使用1(真) // to open the application in the forefront, use 1 (true) //$word->Visible = 0; //打?一个文档 $word->Documents->OPen(”d:\myweb\muban.doc”); //读取文档内容 $test= $word->ActiveDocument->content->Text; echo $test; echo “ ”; //将文档中需要换的变量更换一下 $test=str_replace(””,”这是变量”,$test); echo $test; $word->Documents->Add(); // 在新文档中添加文字 $word->Selection->TypeText(”$test”); //把文档保存在目录中 $word->Documents[1]->SaveAs(”d:/myweb/comtest.doc”); // 关闭与COM组件之间的连接 $word->Quit(); ?>

thinkphp 在新页面输出转换成word文档的问题

8. thinkphp怎么生成word

例如:
$User=D("User");
$User->id=3;
$User->name='ThinkPHp';
$User->save();
echo $User->getLastSql();