diff --git a/README.md b/README.md index 5c94cc7..1baf894 100644 --- a/README.md +++ b/README.md @@ -167,8 +167,8 @@ a simple, but elegant wrapper around [Spout](https://github.com/box/spout) with of simplifying **imports and exports**. It could be considered as a faster (and memory friendly) alternative -to [Laravel Excel](https://laravel-excel.maatwebsite.nl/), with **many less** features. -Use it only for very simple tasks. +to [Laravel Excel](https://laravel-excel.maatwebsite.nl/), with less features. +Use it only for simple tasks. ## Benchmarks diff --git a/composer.json b/composer.json index 59d65eb..3cee064 100644 --- a/composer.json +++ b/composer.json @@ -2,10 +2,11 @@ "name": "rap2hpoutre/fast-excel", "type": "library", "keywords": ["laravel", "excel", "csv", "xls", "xlsx"], + "description": "Fast Excel import/export for Laravel", "require": { "php": "^7.0", - "illuminate/database": "5.3.* || 5.4.* || 5.5.* || 5.6.* || 5.7.*", - "illuminate/support": "5.3.* || 5.4.* || 5.5.* || 5.6.* || 5.7.*", + "illuminate/database": "5.3.* || 5.4.* || 5.5.* || 5.6.* || 5.7.* || 5.8.*", + "illuminate/support": "5.3.* || 5.4.* || 5.5.* || 5.6.* || 5.7.* || 5.8.*", "box/spout": "^2.7" }, "require-dev": { diff --git a/src/Importable.php b/src/Importable.php index d8907ce..5bd12cb 100644 --- a/src/Importable.php +++ b/src/Importable.php @@ -122,7 +122,13 @@ private function importSheet(SheetInterface $sheet, callable $callback = null) } elseif ($count_header < $count_row = count($row)) { $row = array_slice($row, 0, $count_header); } - $collection[] = $callback ? $callback(array_combine($headers, $row)) : array_combine($headers, $row); + if ($callback) { + if ($result = $callback(array_combine($headers, $row))) { + $collection[] = $result; + } + } else { + $collection[] = array_combine($headers, $row); + } } } else { foreach ($sheet->getRowIterator() as $row) { @@ -138,14 +144,16 @@ private function importSheet(SheetInterface $sheet, callable $callback = null) * * @return array */ - private function toStrings($values) { + private function toStrings($values) + { foreach ($values as &$value) { if ($value instanceof \Datetime) { $value = $value->format('Y-m-d H:i:s'); } elseif ($value) { - $value = (string)$value; + $value = (string) $value; } } + return $values; } }