用户
 找回密码
 入住 CI 中国社区
搜索
查看: 5035|回复: 0
收起左侧

[HELP] phpexcel 做导出数据时遇到乱码问题!!

[复制链接]
发表于 2011-11-13 10:49:42 | 显示全部楼层 |阅读模式

<?php   if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Do_output extends CI_Controller {
   function __construct(){
     parent::__construct();
     header('Content-Type:text/html; charset=utf-8,gb2312');
            $this->load->library("phpexcel");
            $this->load->library("PHPExcel/iofactory");
               
    }
    function index(){
    }
  
    function outputExcel(){
       $objPHPExcel = new PHPExcel();//创建一个excel
       $objWriter = IOFactory::createWriter($objPHPExcel, "Excel5");   //2007以下的版本

          //到浏览器
          $outputFileName = date('Y_m_d').'.xls';
          $outputFileName = mb_convert_encoding($outputFileName, "gb2312", "UTF-8");

          header("Content-Type: application/force-download");
          header("Content-Type: application/octet-stream");
          header("Content-Type: application/download");
          header("Content-type:application/vnd.ms-excel");
          header('Content-Disposition:inline;filename="'.$outputFileName.'"');
          header("Content-Transfer-Encoding: binary");
          header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
          header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
          header("Pragma: no-cache");
          $objWriter->save("php://output");
          exit;
         }
}
      

这样不是会输出一个空的excel表格吗?为什么  打开是乱码呢?

本版积分规则