2017-06-17 61 views
1

我有一个问题。我使用Codeigniter框架。我整合了PHPExcel库。它在windows/linux和php 5.X下运行良好。但现在我在linux(Ubuntu)和php 7.0下试过了。它不起作用。为什么?我启用了php_zip,php_gd和php_xml模块,它也不起作用?有任何想法吗?Linux下的Codeigniter PHPExcel

我的代码标识这么简单

$this->load->library("excel"); 
$this->excel->load("/mba/input.xls"); 
echo"test"; 
$this->excel->setActiveSheetIndex(0); 
$this->excel->getActiveSheet()->SetCellValue('B2', "whatever"); 
$this->excel->save("/path/to/output.xls"); 

我看不到测试标签,所以我认为这个问题是各地的“负荷”的一部分。 路径是正确的,并且error.log中没有任何内容。当我检查PHPExcel类时,我找到了加载函数。我发现,问题在于它要加载MY_Excel类,但它不是PHPExcel类的一部分。有任何想法吗?

感谢

回答

0

//控制器

require_once APPPATH . '/third_party/Phpexcel/Bootstrap.php'; 



    // Create new Spreadsheet object 
     $spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet(); 

//Change to excel2007 excel5 

$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, '**Excel5**'); 

$writer->save('php://output');