使用PHPExcel避免在导出到excel时编码特殊字符

时间:2016-11-21 13:29:24

标签: php phpexcel

我正在使用phpexcel以excel格式导出数据,一切正常。但是,当我打开下载的文件时,我看到它将()编码为(),我希望它是()。我搜索了这个,但我不知道该怎么做。

以下是我的代码:

// Rename sheet
    $objPHPExcel->getActiveSheet()->setTitle('Leads');
    // Set active sheet index to the first sheet, so Excel opens this as the first sheet
    $objPHPExcel->setActiveSheetIndex(0);
    // Redirect output to a client’s web browser (Excel5)
    //header('Content-Encoding: UTF-8');
    header('Content-Type: application/vnd.ms-excel; charset=utf-8');
    if ($this->input->post('project_name') == 'all') 
        header('Content-Disposition: attachment;filename="Leads-'.date('d-m-Y H:i:s').'.xls"');
    else 
        header('Content-Disposition: attachment;filename="'.$project_name.'.xls"');
    header('Cache-Control: max-age=0');

    $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
    $objWriter->save('php://output');

0 个答案:

没有答案