moveTo($filename); $xlsx = $reader->load($filename); $worksheet = $xlsx->getActiveSheet(); $rows = $worksheet->getRowIterator(); $dataFound = false; $columns = []; $data = []; foreach ($rows as $row) { $cells = $row->getCellIterator(); $rowData = []; foreach ($cells as $cell) { if ($cell->getColumn() === 'A' and $cell->getCalculatedValue() === "fecha ") { $cols = $row->getColumnIterator(); foreach ($cols as $col) { $columns[$col->getColumn()] = trim($col->getCalculatedValue()); } $dataFound = true; break; } if ($cell->getColumn() === 'A' and $cell->getCalculatedValue() === null) { $dataFound = false; break; } if (!$dataFound) { break; } $col = $columns[$cell->getColumn()]; $value = $cell->getCalculatedValue(); if ($col === 'fecha') { $value = PhpSpreadsheet\Shared\Date::excelToDateTimeObject($cell->getValue(), 'America/Santiago')->format('Y-m-d'); } $rowData[$col] = $value; } if (count($rowData) > 0) { $data []= $rowData; } } unlink($filename); return $data; } }