Laravel-excel: How to count rows of imported excel?

Created on 18 Nov 2015  路  10Comments  路  Source: Maatwebsite/Laravel-Excel

I wish to count the rows of the imported excel. Currently I do something like this:

 $imported = count(\Excel::load($file->getPathName(), function($reader) {})->get());

Most helpful comment

You could use the count method on the Collection

$rows = \Excel::load($file->getPathName(), function($reader) {})->get();

$totalRows = $rows->count();

All 10 comments

I am having the same issue. I would like help on this as well please. Thank You

You could use the count method on the Collection

$rows = \Excel::load($file->getPathName(), function($reader) {})->get();

$totalRows = $rows->count();

@dannyweeks' answer is correct

Thanks for this solution @dannyweeks

How do you prevent laravelexcel from counting empty rows that have borders or some other styling component?

$reader->ignoreEmpty();

@patrickbrouwers
Check how many rows in imported excel file. (version 3.1)

There is an example in the docs in the architecture chapter

$rows = \Excel::load($file->getPathName(), function($reader) {})->get();

$totalRows = $rows->count();

The Load is removed is there any other way to count the rows
@dannyweeks

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lucatamtam picture lucatamtam  路  3Comments

thearabbit picture thearabbit  路  3Comments

gamevnlc picture gamevnlc  路  3Comments

matthewslouismarie picture matthewslouismarie  路  3Comments

bahmanyaghoobi picture bahmanyaghoobi  路  3Comments