Skip to content

Commit

Permalink
Merge branch 'master' of github.com:rap2hpoutre/fast-excel
Browse files Browse the repository at this point in the history
  • Loading branch information
rap2hpoutre committed Feb 27, 2019
2 parents 708ff30 + 21578f4 commit 0f1dd27
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
14 changes: 11 additions & 3 deletions src/Importable.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
}
}

0 comments on commit 0f1dd27

Please sign in to comment.