0

I want to count row in excel file which file i import to db .

    public function import(Request $req)
        {
            $this->validate($req,[
                'select_file' => 'required|mimes: xls,xlsx'
            ],[
                'select_file.required' => 'Vui lòng chọn file',
                'select_file.mimes'    => 'Yêu cầu file .xls hoặc .xlsx'
            ]);
            $data = Excel::import(new ExcelImport, request()->file('select_file'));
            $row = count($data);
        }

It appears an error like this:

count(): Parameter must be an array or an object that implements Countable

Truc Pham
  • 117
  • 3
  • 13

1 Answers1

-3

try using getRowCount getter

$excel = new ExcelImport;
$data = Excel::import($excel, request()->file('select_file'));
$row = $excel->getRowCount();
RH.
  • 32
  • 1
  • 6