SimpleExcel\Parser\XMLParser::getField PHP Method

getField() public method

Get data of all cells as an array
public getField ( boolean $val_only = TRUE ) : array
$val_only boolean Returns (value only | complete data) for every cell, default to TRUE
return array
    public function getField($val_only = TRUE)
    {
        if (!$this->isFieldExists()) {
            throw new \Exception('Field is not set', SimpleExcelException::FIELD_NOT_FOUND);
        }
        if ($val_only) {
            $field = array();
            foreach ($this->table_arr['table_contents'] as $row) {
                $cells = array();
                if ($row['row_contents']) {
                    foreach ($row['row_contents'] as $cell) {
                        array_push($cells, $cell['value']);
                    }
                }
                array_push($field, $cells);
            }
            return $field;
        } else {
            return $this->table_arr;
        }
    }

Usage Example

 /**
  * Change writer type to convert to another format
  * 
  * @param    string  $filetype   Set the filetype of the file which will be written (XML/CSV/TSV/HTML/JSON)
  */
 public function convertTo($filetype)
 {
     $this->constructWriter($filetype);
     $this->writer->setData($this->parser->getField());
 }