使用PHPExcel时获取乱码文本

使用PHPExcel时获取乱码文本,php,phpexcel,Php,Phpexcel,我正在尝试使用PHP Excel生成一个.ods文档。 下面是我正在使用的代码: public function init() { $this->objPHPExcel = new PHPExcel(); } public function indexAction(){ $iexpertsMapper = new Application_Model_IExpertsMapper(); $response = $iexpertsMapper->

我正在尝试使用PHP Excel生成一个.ods文档。 下面是我正在使用的代码:

public function init() {
        $this->objPHPExcel = new PHPExcel();
    }

public function indexAction(){
    $iexpertsMapper = new Application_Model_IExpertsMapper(); 
    $response = $iexpertsMapper->getAllIExpertsPaymentDues();

    $this->objPHPExcel->getProperties()->setCreator("D")
                     ->setLastModifiedBy("D")
                     ->setTitle("D")
                     ->setSubject("D")
                     ->setDescription("D")
                     ->setKeywords("D")
                     ->setCategory("D");
    // Headers
    $this->objPHPExcel->setActiveSheetIndex(0)
            ->setCellValue('A1', 'H')
            ->setCellValue('B1', strtotime("today"))
            ->setCellValue('C1', 'CTPL');

    // Redirect output to a client’s web browser (OpenDocument)
    header('Content-Type: application/vnd.oasis.opendocument.spreadsheet');
    header('Content-Disposition: attachment;filename=bank.ods');
    $objWriter = PHPExcel_IOFactory::createWriter($this->objPHPExcel, 'OpenDocument');
    ob_end_clean();
    $objWriter->save('php://output');
    exit;
}

每当我从浏览器中点击代码时,就会下载一个ods文档,其中包含乱七八糟的文本。我尝试了各种方法,包括添加ob_end_clean();在我的代码中。但似乎什么都不管用。以下文本出现在我的ODS文档中:�QĿi!��K�y3�J
标题(“内容类型:application/vnd.ms-excel;字符集=utf-8”)尝试添加此标题,我不太确定。检查这仍然是胡言乱语。你从哪里得到OpenDocument writer的?找不到它与库捆绑在一起。它是PHP Excel库。这是供参考的示例代码:从我在您的屏幕截图上看到的,这是一个普通XLSX文件的样子。ODS使用相同的技巧,使用Zip文件。我看到您正在进行文本导入,当您双击标题(“内容类型:application/vnd.ms-excel;charset=utf-8”)时会发生这种情况吗尝试添加此标题,我不太确定。检查这仍然是胡言乱语。你从哪里得到OpenDocument writer的?找不到它与库捆绑在一起。它是PHP Excel库。这是供参考的示例代码:从我在您的屏幕截图上看到的,这是一个普通XLSX文件的样子。ODS使用相同的技巧,使用Zip文件。我看到你正在做一个文本导入,当你双击时会发生这种情况吗?