BaseXlsImporter extends BaseImporter<Row, Cell> { @Override public int countRows(byte[] bytes, int sheetIndex) { int count = 0; try (Workbook wb = createReader(bytes, CACHE_SIZE)) { Iterator<Row> iterator = wb.getSheetAt(sheetIndex).iterator(); while (iterator.hasNext()) { Row r = iterator.next(); if (isRowEmpty(r)) { break; } count++; } return count; } catch (IOException ex) { throw new OCSRuntimeException(ex.getMessage()); } }  @Override int countRows(byte[] bytes, int sheetIndex); Workbook createReader(byte[] bytes, int cacheSize); Workbook createWorkbook(byte[] bytes); @Override Double getNumericValueWithDefault(Cell cell, ImportField field); @Override boolean isPercentageCorrectionSupported(); boolean isRowEmpty(Row row); T processRows(Sheet sheet, int firstRowIndex, int colIndex, Class<T> clazz);  }
@Test public void testCountRows() throws IOException { byte[] bytes = readFile("importertest.xlsx"); int rows = importer.countRows(bytes, 0); assertEquals(7, rows); }