@Override
  public KCell[] getRow( int rownr ) {
    // xlsx raw row numbers are 1-based index, KSheet is 0-based

    // Don't check the upper limit as not all rows may have been read!
    // If it's found that the row does not exist, the exception will be thrown at the end of this method.
    if ( rownr < 0 ) {
      // KSheet requires out of bounds here
      throw new ArrayIndexOutOfBoundsException( rownr );
    }
    if ( rownr + 1 < firstRow ) {
      // before first non-empty row
      return new KCell[0];
    }
    if ( rownr > 0 && currentRow == rownr + 1 ) {
      if ( currentRowCells != null ) {
        return currentRowCells;
      }
      // The case when the table contains the empty row(s) before the header
      // but at the same time user wants to read starting from 0 row
      return new KCell[0];
    }
    try {
      if ( currentRow >= rownr + 1 ) {
        // allow random access per api despite performance hit
        resetSheetReader();
      }
      while ( sheetReader.hasNext() ) {
        int event = sheetReader.next();
        if ( event == XMLStreamConstants.START_ELEMENT && sheetReader.getLocalName().equals( TAG_ROW ) ) {
          String rowIndicator = sheetReader.getAttributeValue( null, "r" );
          currentRow = Integer.parseInt( rowIndicator );
          if ( currentRow < rownr + 1 ) {
            continue;
          }
          currentRowCells = parseRow();
          return currentRowCells;
        }
        if ( event == XMLStreamConstants.END_ELEMENT && sheetReader.getLocalName().equals( TAG_SHEET_DATA ) ) {
          // There're no more columns, no need to continue to read
          break;
        }
      }
    } catch ( Exception e ) {
      throw new RuntimeException( e );
    }

    // We've read all document rows, let's update the final count.
    numRows = currentRow;

    // And, as this was an invalid row to ask for, throw the proper exception!
    throw new ArrayIndexOutOfBoundsException( rownr );
  }
@Test
  public void testReadEmptyRow() throws Exception {
    KSheet sheet1 = getSampleSheet();
    KCell[] row = sheet1.getRow( 0 );
    assertEquals( "empty row expected", 0, row.length );
  }