rap2hpoutre / fast-excel

🦉 Fast Excel import/export for Laravel
MIT License
2.09k stars 245 forks source link

Count Row #224

Open zaidysf opened 3 years ago

zaidysf commented 3 years ago

What is the best way to count rows on importing excel without header?

dandragut commented 3 years ago

Wouldn't this work? Headers are just rows, but you should know how many are expected or you can determine them yourself based on containing texts and subtract them from the total number of rows.

ReadableWorkbook workbook    = new ReadableWorkbook(inputStream);
Sheet            worksheet   = workbook.getFirstSheet();
List<Row>        rows        = worksheet.read();
int              numRows     = rows.size();