<?php
/**
 * Created by PhpStorm.
 * User: joe
 * Date: 17-1-22
 * Time: 下午8:43
 */

require 'PHPExcelReader.php';

class Excel {

    public $file,$reader;

    public function __construct($file=null) {
        $this->ci =& get_instance();
        if ($file) {
            $this->setFile($file);
        }
    }

    function setFile($file) {
        $this->file=$file;
        $this->reader = new PHPExcelReader($this->file);
        return $this;
    }

    function getRow($row) {
        $this->reader->seek($row);
        return $this->reader->current();
    }

    function seek($row) {
        $this->reader->seek($row);
        return $this;
    }

    function next() {
        $this->reader-next();
        return $this;
    }

    function count() {
        return $this->reader->count();
    }

    function key() {
        return $this->reader->key();
    }

    function sheet($index) {
        $this->reader->ChangeSheet($index);
        return $this;
    }

    function getAll() {
        foreach($this->reader as $row){
            $data[] = $row;                 // 循环行内数据
        }
        return $data;
    }
}