diergelicheng 2017-05-12 04:01 采纳率: 100%
浏览 851
已采纳

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 哪里要设置下

  • 写回答

1条回答 默认 最新

  • diergelicheng 2017-05-12 04:03
    关注

    问题解决了C币再加几倍都可以

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题