New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Question] How to skip empty rows (3.1) #1861
Comments
Thanks for submitting the ticket. Unfortunately the information you provided is incomplete. We need to know which version you use and how to reproduce it. Please include code examples. Before we can pick it up, please check (https://github.com/Maatwebsite/Laravel-Excel/blob/3.0/.github/ISSUE_TEMPLATE.md) and add the missing information. To make processing of this ticket a lot easier, please make sure to check (https://laravel-excel.maatwebsite.nl/docs/3.0/getting-started/contributing) and double-check if you have filled in the issue template correctly. This will allow us to pick up your ticket more efficiently. Issues that follow the guidelines correctly will get priority over other issues. |
Duplicate of #1834 |
use ToCollection method the wrap everything within
|
How does it work for the toModel way? |
You can return null in toModel, will skip those rows. |
Hello,
Unfortunately, if you have an excel file an delete the content of some rows at the end of the excel file Laravel-Excel still recognizes them as not empty. Then the validation fails. I want to skip such rows before validation. |
@seven21 , did you find a solution for this ? does anyone got resolved this issue ? |
I use a workaround which helps in my case. Validation is extended by nullable on all rows to avoid errors and then In the method I have added |
@seven21 Thank you very much for your instance and useful message, But I'm also thinking this isn't a good way if we actually using validations. |
@mohamednizar how did you resolve this issue? |
I didn't completely resolve the issue, but for my solution I added following custom functions to return the batch size and row limit. the row limit only will be count if data exists in the column.
Some time this may help you to resolve some sort of problems. |
you can ignore the empty row by updating the config/excel.php file. from: /*
|--------------------------------------------------------------------------
| Ignore Empty
|--------------------------------------------------------------------------
|
| When dealing with imports, you might be interested in ignoring
| rows that have null values or empty strings. By default rows
| containing empty strings or empty values are not ignored but can be
| ignored by enabling the setting ignore_empty to true.
|
*/
'ignore_empty' => false, to: /*
|--------------------------------------------------------------------------
| Ignore Empty
|--------------------------------------------------------------------------
|
| When dealing with imports, you might be interested in ignoring
| rows that have null values or empty strings. By default rows
| containing empty strings or empty values are not ignored but can be
| ignored by enabling the setting ignore_empty to true.
|
*/
'ignore_empty' => true, |
@whoami213 It works. Thanks a lot man |
Description
How to skip empty rows in the doc?
The text was updated successfully, but these errors were encountered: