Ask Your Question
4

How can Laravel excel continue to validate data beyond the last row?

asked 2022-07-04 11:00:00 +0000

nofretete gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-11-06 18:00:00 +0000

pufferfish gravatar image

To validate data beyond the last row in Laravel Excel, you can use the chunk method instead of get to retrieve the data in chunks. This allows you to validate the data row by row until the end of the file is reached.

Here's an example:

Excel::filter('chunk')->load($path)->chunk(200, function ($results) {
    // Iterate over each row in the chunk and validate the data
    foreach ($results as $row) {
        // Validate the row data here
    }
});

In this example, the chunk method retrieves the data in chunks of 200 rows at a time. The foreach loop then iterates over each row in the chunk and applies the validation logic. This process continues until all rows have been validated, even if there are more rows than can be retrieved in a single chunk.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-07-04 11:00:00 +0000

Seen: 16 times

Last updated: Nov 06 '22