setupReader(); } /** * устанавливает ридер и его параметры */ protected function setupReader() { require_once 'ExcelReader/reader.php'; $this->reader = new \Spreadsheet_Excel_Reader(); $this->reader->setOutputEncoding( $this->encoding ); $this->reader->read( $this->file_path ); } public function read() { parent::read(); $this->cleanUp(); return $this->result; } protected function readRow( ) { $this->row = []; $current_sheet = $this->reader->sheets[ $this->active_sheet ]; for ( $j = 1; $j <= $current_sheet['numCols']; $j++ ) { if ( isset( $current_sheet['cells'][ $this->current_row_number ][$j]) ) $this->row[] = $current_sheet['cells'][ $this->current_row_number ][$j]; } } protected function isEmptyRow(){ $is_empty = false; if ( !$this->row ) { return true; } if ( count( $this->row ) < $this->min_column_quantity ) { return true; } $j = 0; for ($i = 1; $i <= count( $this->row ); $i++) { if ( !isset( $this->row[ $i - 1 ] ) ) { continue; } if ( $this->isEmptyColumn( $this->row[$i - 1] ) ) { $j++; } if ( $j >= $this->min_column_quantity ) { $is_empty = true; break; } } return $is_empty; } protected function isEmptyColumn( $val ){ return $val == ''; } protected function setResult( ){ $this->result[] = $this->row; } }