Konvertiert ein Excel in einen Array

Erwartet excelFile als Uploaded File
der zurückgegebene Array hat jedoch keine Zahlen Columns sondern auch einen 0 basierten index
auch die Rows sind 0 basierend

@controller-api
@return array
774410
public function convert(\stdClass $table, $excelFile = NULL, $removeEmpty = TRUE) {
    $excelFile = $excelFile ?: $this->v->validateUploadedFile('excelFile');
    
    $reader = PHPExcel_IOFactory::createReaderForFile((string) $excelFile);
    $excel = $reader->load((string) $excelFile);
    $sheet = $excel->getSheet(0);
    
    $columns = isset($table->columns) ? (array) $table->columns : array();
    
    $nullValue = ''; // sadly json macht aus NULL den string "null" in js
    $data = array();
    $mCell = 0;
    foreach ($sheet->getRowIterator() as $wsRow) {
      $row = array();
      $empty = TRUE;
      foreach ($wsRow->getCellIterator() as $cell) {
        // $cell->getDataType() gibts sogar auch

        $cellIndex = h::getColumnIndex($cell->getColumn());
        $mCell = max($mCell, $cellIndex+1);
      
        $row[$cellIndex] = $value = $this->convertValue(
                            $cell->getValue(),
                            isset($columns[$cellIndex]) && isset($columns[$cellIndex]->type) ? $columns[$cellIndex]->type : NULL
                           );
        if ($value != '') {
          $empty = FALSE;
        }
      }
      
      if (!$removeEmpty || !$empty) {
        ksort($row);
        $data[] = array_replace(array_fill(0, $mCell, $nullValue), $row);
      }
    }

    return new ServiceResponse(Service::OK, $data, ServiceResponse::JSON_UPLOAD_RESPONSE);
  }
648866
protected List<ExcelFile> getExcelFiles() {
		if (excelFiles == null) {
			excelFiles = newArrayListWithCapacity(3);

			for (int i = 0;; ++i) {
				String baseKey = String.format("dataSource.%s.%d", getName(), i);
				String path = configuration.get(baseKey + ".path");
				if (path == null) {
					break;
				}
				String doString = configuration.get(baseKey + ".dataOrientation", "rowbased");
				DataOrientation dataOrientation = DataOrientation.valueOf(doString);

				log.info("Opening Excel file: {}", path);
				ExcelFile file = new ExcelFile(new File(path), dataOrientation, dataFormatter);

				try {
					file.load();
				} catch (InvalidFormatException ex) {
					throw new JFunkException(ex.getMessage(), ex);
				} catch (IOException ex) {
					throw new JFunkException(ex.getMessage(), ex);
				}

				excelFiles.add(file);
			}
		}
		return excelFiles;
	}
309341
public function findAll() {
    $sheets = array();
    
    foreach ($this->readSelectedSheets() as $selectName => $excelSheet) {
      $sheets[$selectName] = new Sheet($selectName, $this->readRows($excelSheet));
    }
    
    return $sheets;
  }
960281
protected function modelToYamlArray()
    {
        $fileColumns = [];

        foreach ($this->columns as $column) {
            if (!isset($column['field'])) {
                throw new ApplicationException('Cannot save the list - the column field name should not be empty.');
            }

            $columnName = $column['field'];
            unset($column['field']);

            if (array_key_exists('id', $column)) {
                unset($column['id']);
            }

            $column = $this->preprocessColumnDataBeforeSave($column);

            $fileColumns[$columnName]  = $column;
        }

        return [
            'columns'=>$fileColumns
        ];
    }
687199
public function toArray()
    {
        return [
            'id' => $this->id,
            'filename' => $this->filename,
            'filetype' => $this->filetype,
            'filesize' => $this->filesize,
            'tags' => $this->tags,
            'preview_url' => $this->previewUrl(),
            'url' => $this->downloadUrl()
        ];
    }
1374225
public function toArray()
    {
        return array_filter(
            array(
                'method' => $this->getMethod(),
                'url' => $this->getUrl(),
                'headers' => $this->getHeaders(),
                'body' => $this->getBody(),
                'post_files' => $this->getPostFiles(),
                'post_fields' => $this->getPostFields(),
            )
        );
    }
66221
public function toArray()
	{
		$result = parent::toArray();

		if (isset($result['suspended']))
		{
			$result['suspended'] = $this->getSuspendedAttribute($result['suspended']);
		}
		if (isset($result['banned']))
		{
			$result['banned'] = $this->getBannedAttribute($result['banned']);
		}
		if (isset($result['last_attempt_at']) and $result['last_attempt_at'] instanceof DateTime)
		{
			$result['last_attempt_at'] = $result['last_attempt_at']->format('Y-m-d H:i:s');
		}
		if (isset($result['suspended_at']) and $result['suspended_at'] instanceof DateTime)
		{
			$result['suspended_at'] = $result['suspended_at']->format('Y-m-d H:i:s');
		}

		return $result;
	}
355618
public function getFilesArray()
    {
        if ($this->_filesArray === null) {
            $this->_filesArray = $this->getQueryCacheHelper((new Query())->from('{{%admin_storage_file}}')->select(['id', 'is_hidden', 'is_deleted', 'folder_id', 'name_original', 'name_new', 'name_new_compound', 'mime_type', 'extension', 'hash_name', 'hash_file', 'upload_timestamp', 'file_size', 'upload_user_id', 'caption'])->indexBy('id'), self::CACHE_KEY_FILE);
        }

        return $this->_filesArray;
    }
97679
protected function getData()
    {
        if (is_null($this->order[0])) {
            return $this->table->data['data'];
        }

        $items  = $this->table->data['data'];
        $col    = $this->order[0];
        $order  = $this->order[1];

        usort($items, function ($a, $b) use ($col, $order) {
            if (!isset($a[$col]) && !isset($b[$col])) {
                return 0;
            }

            if (is_array($a[$col]) || is_array($b[$col])) {
                return 0;
            }

            if (!isset($a[$col]) || is_array($a[$col])) {
                return $order == 'asc' ? -1 : 1;
            }

            if (!isset($b[$col]) || is_array($b[$col])) {
                return $order == 'asc' ? 1 : -1;
            }

            return $order == 'asc'
                ? strnatcmp((string) $a[$col], (string) $b[$col])
                : strnatcmp((string) $b[$col], (string) $a[$col]);
        });

        return $items;
    }
973547
public function getKeys()
    {
        /** @var \DOMNodeList $tmp */
        $transUnits = $this->getXPath()->query('/xliff:xliff/xliff:file/xliff:body/xliff:trans-unit');

        $result = array();

        if ($transUnits->length > 0) {
            /** @var \DOMElement $element */
            foreach ($transUnits as $element) {
                if (!$this->getAttribute($element, 'id')) {
                    throw new \Exception('Empty Id: ' . var_export($element, true));
                }
                $result[] = (string) $this->getAttribute($element, 'id');
            }
        }

        return $result;
    }
950292
public function toArray()
	{
		$array = array();

		for ($index = 0; $index < $this->size; $index++)
		{
			$array[] = (bool) (ord($this->data[(int) ($index / 8)]) & (1 << $index % 8));
		}

		return $array;
	}
1122810
public function toStrictArray() {
        $colsArray = $this->getColArray();
        
        $rowsArray = $this->rows;
        
        array_walk($rowsArray, function (&$item, $key, $cols) {
            $item = array('c' => $item->toMatchingArray($cols));
        }, $this->cols);

        return self::getFilteredArray($colsArray, $rowsArray, $this->p);
        
    }
1263129
public function jsonRows()
    {
        $arrWhat = array_values($this->getHeaderColumns());
        $arrWhere = [];
        $arrOrder = ['`id` DESC'];
        $start = 0;
        $pageSize = 15;
        if (isset($_POST['page']) && isset($_POST['pageSize'])) {
            $page = (int) $_POST['page'];
            $pageSize = (int) $_POST['pageSize'];
            $start = $page * $pageSize;
        }
        if (isset($_POST['sort']) && isset($_POST['sortDir'])) {
            $sort = (string) $_POST['sort'];
            $sortDir = (string) $_POST['sortDir'];
            if (!in_array($sortDir, ['ASC', 'DESC'])) {
                throw new Exception('Someone is doing something evil here :(');
            }
            if (!in_array($sort, $this->getAllowedPostColumns())) {
                throw new Exception('Someone is doing something evil here :(');
            }
            $arrOrder = ['`'.$sort.'` '.$sortDir];
        }
        foreach ($arrWhat as $filter) {
            if (in_array($filter, $arrWhat) && isset($_POST['filter_'.$filter])) {
                $arrWhere[$filter] = [
                    "operator" => "like",
                    "value" => '%'.$_POST['filter_'.$filter].'%'
                ];
            }
        }
        
        $arrLimit = [$start, $pageSize];
        $rows = $this->loadByPrepStmt($arrWhat, $arrWhere, $arrOrder, $arrLimit);
        if (count($rows) < 1) {
            return "[]";
        }
        foreach ($rows as $key => $columns) {
            foreach ($columns as $cKey => $column) {
                if ($cKey == "createDate") {
                    $rows[$key][$cKey] = strftime("%d.%m.%Y %H:%M:%S", strtotime($column));
                }
            }
            $rows[$key]['actions'] = $this->renderActionLinks();
        }
        $json = json_encode($rows, JSON_UNESCAPED_UNICODE);
        return $json;
    }
1276966
public function data() : array
    {
        $data = array();

        $data['classes'] = implode(' ', apply_filters('Modularity/Module/Classes', array('box', 'box-index'), $this->post_type, $this->args));

        // Get column classes
        $data['columnClass'] = 'grid-md-6';
        if (!empty(get_field('index_columns', $this->ID))) {
            $data['columnClass'] = get_field('index_columns', $this->ID);
        }

        $data['imageDimension'] = $this->getImageDimension($data['columnClass']);

        // Get the index items
        $data['items'] = $this->prepareItems(get_field('index', $this->ID));

        return $data;
    }
878803
public function toArray()
    {
        return array(
            'email' => $this->getEmail(),
            'telno' => $this->getTelno(),
            'cellno' => $this->getCellno(),
            'fname' => $this->getFirstName(),
            'lname' => $this->getLastName(),
            'company' => $this->getCompanyName(),
            'careof' => $this->getCareof(),
            'street' => $this->getStreet(),
            'house_number' => $this->getHouseNumber(),
            'house_extension' => $this->getHouseExt(),
            'zip' => $this->getZipCode(),
            'city' => $this->getCity(),
            'country' => $this->getCountry(),
        );
    }
273948
public function prepareExportFileVariables() : array {
		$result = [
			'success' => false,
			'error' => [],
			'data' => []
		];
		// details
		$details = [];
		if (!empty($this->collection['details'])) {
			$this->disassembleCollectionObject($this->collection['details'], $details);
		}
		// step 1: fields
		$result['data'][$this->collection['name']] = [];
		foreach ($this->fields as $k => $v) {
			if (!$this->skipExportField($k, $v)) continue;
			// if we have detail
			if (!empty($details[$k])) {
				$result['data'][$details[$k]['name']] = [];
				foreach ($details[$k]['pk'] as $k2 => $v2) {
					if ($k2 == 0 && strpos($v2, 'tenant_id') !== false) continue;
					$result['data'][$details[$k]['name']][0][$v2] = $v2;
				}
				continue;
			}
			// regular field
			$result['data'][$this->collection['name']][0][$k] = $k;
		}
		// step 2: detail fields
		foreach ($this->detail_fields as $k => $v) {
			$result['data'][$details[$k]['name']] = [];
			// add pk
			foreach ($details[$k]['pk'] as $k2 => $v2) {
				if ($k2 == 0 && strpos($v2, 'tenant_id') !== false) continue;
				$result['data'][$details[$k]['name']][0][$v2] = $v2;
			}
			// add fields
			foreach ($v['elements'] as $k2 => $v2) {
				if (!$this->skipExportField($k2, $v2)) continue;
				$result['data'][$details[$k]['name']][0][$k2] = $k2;
			}
		}
		$result['success'] = true;
		return $result;
	}
816075
public function getValuesAsArray()
    {
        //converts the files array with multiple values into PHP's ugly format
        //http://php.net/manual/en/reserved.variables.files.php#89674
        if ($this->files) {
            $parsedFileArray = [];
            foreach ($this->files as $name => $file) {
                if (!isset($file['name'])) {
                    if (!isset($parsedFileArray[$name])) {
                        $parsedFileArray[$name]['name'] = [];
                        $parsedFileArray[$name]['type'] = [];
                        $parsedFileArray[$name]['tmp_name'] = [];
                        $parsedFileArray[$name]['error'] = [];
                        $parsedFileArray[$name]['size'] = [];
                    }
                    foreach ($file as $subfile) {
                        $parsedFileArray[$name]['name'][] = $subfile['name'];
                        $parsedFileArray[$name]['type'][] = $subfile['type'];
                        $parsedFileArray[$name]['tmp_name'][] = $subfile['tmp_name'];
                        $parsedFileArray[$name]['error'][] = $subfile['error'];
                        $parsedFileArray[$name]['size'][] = $subfile['size'];
                    }
                } else {
                    $parsedFileArray[$name] = $file;
                }
            }
        }

        return [
            'post'  => $this->post,
            'files' => isset($parsedFileArray) ? $parsedFileArray : $this->files
        ];
    }