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 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥20 想用ollama做一个自己的AI数据库
  • ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
  • ¥15 请问怎么才能复现这样的图呀