2013-01-15 41 views
1

我已经下载的PHP练成出口图书馆从http://phpexportxlsclass.googlecode.com/files/export-xls.class-v1.01.zip笨Excel的编码问题

,如果我从zip运行demo.php文件independantly它工作正常。

我已经包括出口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(); 
} 

但是当我运行使用URL http://www.domain.com/controller/export_to_excel然后我的代码它会给我下面的excel文件作为输出。 enter image description here

回答

0

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

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

看到this在这一问题上进行更多的讨论。