/** * @brief Parsing Excel table into PHP class Table. * @param string $excel Form input with Excel table * @return \models\Table Table with parsed data */ public function parseExcel($excel) { $rows_parsed = $this->explodeExcelRows($excel); // Exploding rows of input $table = new Table(); // Creating new table $table->name = trim($rows_parsed[0]); // The first row is table name $table->cols = $this->parseCols($rows_parsed[1]); // The second row are table columns unset($rows_parsed[0]); // Delete the first row unset($rows_parsed[1]); // Delete the second row (remain data rows only) foreach ($rows_parsed as $index => $row) { // Browsing each data row... $table->rows[] = $this->parseRow($row); // Parsing column values of one row } $table->clearWrongRows(); // Clearing rows with wrong number of columns return $table; // Returning whole table with parsed data }