Codeigniter excel编码问题

我已经从http://phpexportxlsclass.googlecode.com/files/export-xls.class-v1.01.zip下载php excel导出器库

它工作正常,如果我运行demo.php文件独立于zip。

我已经在库文件夹中包含export-xls.class.php文件,并从控制器调用该库

这里是代码片段

function export_to_excel() { require(APPPATH.'libraries/exportxls.php'); $config['filename'] = 'test1.xls'; // The file name you want any resulting file to be called. $xls = new ExportXLS($config); $xls->addHeader("Test Spreadsheet"); $xls->addHeader(null); $header = array("Name", "Age", "Height"); $xls->addHeader($header); $row = array(); $row[] = array('Jack', '24', '6ft'); $row[] = array('Jim', '22', '5ft'); $row[] = array('Jess', '54', '4ft'); $row[] = array('Luke', '6', '2ft'); $xls->addRow($row); $xls->sendFile(); } 

但是当我运行我的代码使用urlhttp://www.domain.com/controller/export_to_excel然后它会给我下面的excel文件作为输出。 在这里输入图像说明

对于Windows支持:在私有函数textFormat($row, $col, $data)添加这些行

 iconv("UTF-8", "CP1252", $data); 

看到这个问题的更多讨论。