CodeIgniter with PHPExcel fatal error cannot redeclare class IOFactory

后端 未结 3 441
情书的邮戳
情书的邮戳 2021-01-25 18:10

I\'m trying to use PHPExcel with CodeIgniter.

My problem is when i want to use this method below, I got PHP Fatal Error : Cannot redeclare class IOFactory

3条回答
  •  抹茶落季
    2021-01-25 18:48

    No need to write

    $this->load->library('PHPExcel');
    

    Just start with

    $this->load->library('PHPExcel/IOFactory');
    

    Edited :::

    In my project I have done by these way,

    Step1: in libraries\PHPExcel\Reader

    Rename Excel5.php to PHPExcel_Reader_Excel5.php

    Step2:

    $filePath = $dir.$uploadedfile;
    $objReader = $this->load->library('PHPExcel/Reader/PHPExcel_Reader_Excel5', $filePath);
    $objReader = new PHPExcel_Reader_Excel5();
    $objPHPExcel = $objReader->load($filePath);     
    $rowIterator = $objPHPExcel->getActiveSheet()->getRowIterator();                        
    $sheet = $objPHPExcel->getActiveSheet();
    $maxRowIndex = $sheet->getHighestRow();
    $highestColumn = $sheet->getHighestColumn();
    $maxColIndex = PHPExcel_Cell::columnIndexFromString($highestColumn);
    

提交回复
热议问题