rap2hpoutre / fast-excel

🦉 Fast Excel import/export for Laravel
MIT License
2.11k stars 247 forks source link

[Enhancement] Optional import return data #242

Open mcolominas opened 3 years ago

mcolominas commented 3 years ago

From what I've seen, when you import data, at the end it returns an collection with the imported data.

Would it be possible to add an option so that it does not return anything to improve performance?

For example, you have to import in csv with 100000 lines, having an array with so many lines is not very good.

This would be an example:

if ($callback) {
    if ($result = $callback(empty($headers) ? $row : array_combine($headers, $row))) {
        if(self::$return_data)
            $collection[] = $result;
        //Or
        if(!is_null($result))
            $collection[] = $result;
    }
} else {
    $collection[] = empty($headers) ? $row : array_combine($headers, $row);
}

As you can see in the example, this enhancement is only available in case of a callback