iofactory.php,CodeIgniter中的PHPExcel错误“无法加载请求的类:iofactory”

我之前已成功使用PHPExcel和CodeIgniter.

我所做的就是将phpexcel文件夹放入application / third-party并创建以下包装器库:

class Excel {

private $excel;

public function __construct() {

// initialise the reference to the codeigniter instance

require_once APPPATH.'third_party/phpexcel/PHPExcel.php';

$this->excel = new PHPExcel();

}

public function load($path) {

$objReader = PHPExcel_IOFactory::createReader('Excel5');

$this->excel = $objReader->load($path);

}

public function save($path) {

// Write out as the new file

$objWriter = PHPExcel_IOFactory::createWriter($this->excel, 'Excel5');

$objWriter->save($path);

}

public function stream($filename) {

header('Content-type: application/ms-excel');

header("Content-Disposition: attachment; filename=\"".$filename."\"");

header("Cache-control: private");

$objWriter = PHPExcel_IOFactory::createWriter($this->excel, 'Excel5');

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

}

public function __call($name, $arguments) {

// make sure our child object has this method

if(method_exists($this->excel, $name)) {

// forward the call to our child object

return call_user_func_array(array($this->excel, $name), $arguments);

}

return null;

}

}

?>

然后我可以在我的控制器中执行以下操作:

$this->load->library("excel");

$this->excel->load("/path/to/input.xls");

$this->excel->setActiveSheetIndex(0);

$this->excel->getActiveSheet()->SetCellValue('B2', "whatever");

$this->excel->save("/path/to/output.xls");

希望这可以帮助你?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值