SpartnerNL / Laravel-Excel

🚀 Supercharged Excel exports and imports in Laravel
https://laravel-excel.com
MIT License
12.28k stars 1.92k forks source link

[Bug]: When exporting csv of more than 1001 rows, if NO header rows are used, the output file is only 1000 rows #4098

Closed realtebo closed 5 months ago

realtebo commented 7 months ago

Is the bug applicable and reproducable to the latest version of the package and hasn't it been reported before?

What version of Laravel Excel are you using?

3.1.55

What version of Laravel are you using?

10.46.0

What version of PHP are you using?

8.1.3

Describe your issue

I hopw this issue will find you well.

I am exporting a huge amount of data, more than 10.000 rows

If we DO NOT use the concern "WIthHeadings", the output file is only 1.000 rows.

We think the problem is thiscode block: https://github.com/SpartnerNL/Laravel-Excel/blob/3.1/src/Sheet.php#L658-L676

Because when the code estabilish if the first line is not empty, actually is returning always false. So the export restart overwriting, at each 1000 rows of chunk, as per your code, from first line.

This behaviour doesn't happens if using an heading row.

But we absolutely need to do not have heading rows in our file.

How can the issue be reproduced?

Try to export a csv with a few of thousands of rows without WithHeadings Concerns

What should be the expected behaviour?

Every rows should be saved into file, not last 1.000

realtebo commented 7 months ago

After digging into the rabbit hole for half a day, one genius, a coworker, found the trigger, the root cause of the bug

All starts because we have to export a strange csv file where _the first column of the first line is an empty cell. AND we have no headings in the csv

When your (excellent and unreplaceable) code try to understand if there are data already exported, read the 'a1' cell and checks if it's populated. So it's a false negative, in this case, and the code thinks there are no already exported data, and so, restart from 'a1' and override in the Sheet class the whole already exported data.

realtebo commented 7 months ago

Here again to add another detail.

We had success adding WithStrictNullComparision concern.

Using this workaround, the performance are a bit worse than without using it, but we can succesfully export all rows, without using headers, in a situation when a1 cell is always empty

stale[bot] commented 5 months ago

This bug report has been automatically closed because it has not had recent activity. If this is still an active bug, please comment to reopen. Thank you for your contributions.