Use SimpleExcelReader::create($path) to initialize a reader. For CSV files, ensure the path ends in .csv. For Excel files, ensure it ends in .xlsx.
Calling getRows() returns an instance of Illuminate extbackslash Support extbackslash LazyCollection, which allows for memory-efficient processing of large files using generators. You can use standard Laravel collection methods like each(), filter(), take(), or skip() on the result.
use Spatie\SimpleExcel\SimpleExcelReader;
// Returns a LazyCollection
$rows = SimpleExcelReader::create($pathToCsv)->getRows();
$rows->each(function(array $rowProperties) {
// $rowProperties contains column data as associative array
});