zend framework 导出 下载
我这里一个系统,用的是 zend frame 框架和sqlite数据库,本来没问题,后改成mysql数据库,其他正常,就是导出word,excel,以及下载都有问题了,导出的文件和下载的文件都不正常,打不开了
一下是导出word的代码:
/**
* 导出视频评论的word文档
*/
public function exportcomments1Action() {
$vid = $_GET['vid'];
require_once "PHPWord/PHPWord.php";
$PHPWord = new PHPWord();
$section = $PHPWord->createSection();
$PHPWord->addFontStyle('r1Style', array('color'=>'000000','bold'=>true, 'italic'=>false, 'size'=>12));
$PHPWord->addFontStyle('r2Style', array('color'=>'000000','bold'=>false, 'italic'=>false, 'size'=>11));
$sql = "";
$sql = "select * from videocomment where vid='$vid' and is_active='1' order by time asc";
$comments = $this->db->Execute($sql);
// $comments = D('VideoComment') -> getCommentsByVid($vid);
$sql = "";
$sql = "select * from video_tmp where id='$vid'";
$videoinfo = $this->db->getRow($sql);
// $videoinfo = D('Video') -> getVideoByVid($vid);
$videoname = $videoinfo["title"];
// $videouid = $videoinfo['uid'];
$sql = "";
$videoowner="jkl";
// $videoowner = D('User') -> getDisplayName($videouid);
$header = $section->createHeader();
$header->addText('[专家视频点评汇总]',array('bold'=>false,'size'=>10,'underline'=>single),array('align'=>'right'));
$section->addText('视频编号为'.$vid.'的专家点评汇总', 'r1Style');
$section->addTextBreak(1);
// $section->addText('视频名称:'.$videoname.' '.'上传人:'.$videoowner, 'r1Style');
$section->addText('视频名称:'.$videoname, 'r1Style');
$section->addTextBreak(1);
$table = $section->addTable();
$table->addRow();
// $table->addCell(5000)->addText("点评图片",'r2Style');
$table->addCell(5000)->addText("专家点评",'r2Style');
foreach ($comments as &$c) {
$table->addRow();
// $c['dname'] ="二的";
// $c['dname'] = D('User') -> getDisplayName($c['uid']);
// $table->addCell(5000)->addImage($c['thumb_path'],array('width'=>250, 'height'=>250));
$comment_content = "专家—的点评:".$c['content'];
$table->addCell(5000)->addText($comment_content,'r2Style');
}
// Save File
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
$filename = '视频评论导出'.$vid.'.docx';//要保存的文件名
$filename=iconv("utf-8","gb2312",$filename);
$filepath = sys_get_temp_dir().'/'.$filename; //要下载的文件地址
$objWriter->save($filepath);
ob_end_clean();
header("Content-Type: application/force-download");
header("Content-Disposition: attachment; filename=".$filename);
readfile($filepath);
exit();
}
我把上面代码中和数据库有关的代码都去掉,只随意写几个字母数字进去,导出来也不正常,下载也是一样。估计是zend framework 哪里要设置下
一下是导出word的代码:
/**
* 导出视频评论的word文档
*/
public function exportcomments1Action() {
$vid = $_GET['vid'];
require_once "PHPWord/PHPWord.php";
$PHPWord = new PHPWord();
$section = $PHPWord->createSection();
$PHPWord->addFontStyle('r1Style', array('color'=>'000000','bold'=>true, 'italic'=>false, 'size'=>12));
$PHPWord->addFontStyle('r2Style', array('color'=>'000000','bold'=>false, 'italic'=>false, 'size'=>11));
$sql = "";
$sql = "select * from videocomment where vid='$vid' and is_active='1' order by time asc";
$comments = $this->db->Execute($sql);
// $comments = D('VideoComment') -> getCommentsByVid($vid);
$sql = "";
$sql = "select * from video_tmp where id='$vid'";
$videoinfo = $this->db->getRow($sql);
// $videoinfo = D('Video') -> getVideoByVid($vid);
$videoname = $videoinfo["title"];
// $videouid = $videoinfo['uid'];
$sql = "";
$videoowner="jkl";
// $videoowner = D('User') -> getDisplayName($videouid);
$header = $section->createHeader();
$header->addText('[专家视频点评汇总]',array('bold'=>false,'size'=>10,'underline'=>single),array('align'=>'right'));
$section->addText('视频编号为'.$vid.'的专家点评汇总', 'r1Style');
$section->addTextBreak(1);
// $section->addText('视频名称:'.$videoname.' '.'上传人:'.$videoowner, 'r1Style');
$section->addText('视频名称:'.$videoname, 'r1Style');
$section->addTextBreak(1);
$table = $section->addTable();
$table->addRow();
// $table->addCell(5000)->addText("点评图片",'r2Style');
$table->addCell(5000)->addText("专家点评",'r2Style');
foreach ($comments as &$c) {
$table->addRow();
// $c['dname'] ="二的";
// $c['dname'] = D('User') -> getDisplayName($c['uid']);
// $table->addCell(5000)->addImage($c['thumb_path'],array('width'=>250, 'height'=>250));
$comment_content = "专家—的点评:".$c['content'];
$table->addCell(5000)->addText($comment_content,'r2Style');
}
// Save File
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
$filename = '视频评论导出'.$vid.'.docx';//要保存的文件名
$filename=iconv("utf-8","gb2312",$filename);
$filepath = sys_get_temp_dir().'/'.$filename; //要下载的文件地址
$objWriter->save($filepath);
ob_end_clean();
header("Content-Type: application/force-download");
header("Content-Disposition: attachment; filename=".$filename);
readfile($filepath);
exit();
}
我把上面代码中和数据库有关的代码都去掉,只随意写几个字母数字进去,导出来也不正常,下载也是一样。估计是zend framework 哪里要设置下
...全文
相关推荐
(zf2)zend framework 2官方文档pdf
zf2官方英文版文档,2013年5月份最新
1、开始使用Symfony、CakePHP和Zend Framework
本博文详细介绍了如何搭建Symfony、CakePHP和Zend Framework的托管环境,并通过具体步骤展示了这三个PHP框架的安装、配置及创建简单的Hello World应用程序的过程。同时,深入探讨了基于这些框架开发一个在线地址簿应用的设计与实现,帮助开发者快速上手并掌握实际项目开发技能。
zend framework 中文手册下载
学习php,学习框架,学习zend framework。手册不可缺少。
zend framework
zend framework 框架源码下载
Zend Framework开发入门经典教程
主要介绍了Zend Framework开发入门知识点,详细介绍了Zend Framework开发的zend源码下载,环境配置,基本组件使用与相关注意事项等,需要的朋友可以参考下


Framework
