@Test public void testReadRowRA() throws Exception { KSheet sheet1 = getSampleSheet(); KCell[] row = sheet1.getRow( 4 ); assertEquals( "Three", row[1].getValue() ); row = sheet1.getRow( 2 ); assertEquals( "One", row[1].getValue() ); }
@Override public KCell[] getRow( int rownr ) { if ( rownr < 0 || rownr >= numRows ) { throw new ArrayIndexOutOfBoundsException( rownr ); } if ( rownr + 1 < firstRow ) { return new KCell[0]; } if ( rownr > 0 && currentRow == rownr + 1 ) { return currentRowCells; } try { if ( currentRow >= rownr + 1 ) { resetSheetReader(); } while ( sheetReader.hasNext() ) { int event = sheetReader.next(); if ( event == XMLStreamConstants.START_ELEMENT && sheetReader.getLocalName().equals( "row" ) ) { String rowIndicator = sheetReader.getAttributeValue( null, "r" ); currentRow = Integer.parseInt( rowIndicator ); if ( currentRow < rownr + 1 ) { continue; } currentRowCells = parseRow(); return currentRowCells; } } } catch ( Exception e ) { throw new RuntimeException( e ); } numRows = currentRow; return new KCell[] {}; }
StaxPoiSheet implements KSheet { @Override public KCell[] getRow( int rownr ) { if ( rownr < 0 || rownr >= numRows ) { throw new ArrayIndexOutOfBoundsException( rownr ); } if ( rownr + 1 < firstRow ) { return new KCell[0]; } if ( rownr > 0 && currentRow == rownr + 1 ) { return currentRowCells; } try { if ( currentRow >= rownr + 1 ) { resetSheetReader(); } while ( sheetReader.hasNext() ) { int event = sheetReader.next(); if ( event == XMLStreamConstants.START_ELEMENT && sheetReader.getLocalName().equals( "row" ) ) { String rowIndicator = sheetReader.getAttributeValue( null, "r" ); currentRow = Integer.parseInt( rowIndicator ); if ( currentRow < rownr + 1 ) { continue; } currentRowCells = parseRow(); return currentRowCells; } } } catch ( Exception e ) { throw new RuntimeException( e ); } numRows = currentRow; return new KCell[] {}; } }
StaxPoiSheet implements KSheet { @Override public KCell[] getRow( int rownr ) { if ( rownr < 0 || rownr >= numRows ) { throw new ArrayIndexOutOfBoundsException( rownr ); } if ( rownr + 1 < firstRow ) { return new KCell[0]; } if ( rownr > 0 && currentRow == rownr + 1 ) { return currentRowCells; } try { if ( currentRow >= rownr + 1 ) { resetSheetReader(); } while ( sheetReader.hasNext() ) { int event = sheetReader.next(); if ( event == XMLStreamConstants.START_ELEMENT && sheetReader.getLocalName().equals( "row" ) ) { String rowIndicator = sheetReader.getAttributeValue( null, "r" ); currentRow = Integer.parseInt( rowIndicator ); if ( currentRow < rownr + 1 ) { continue; } currentRowCells = parseRow(); return currentRowCells; } } } catch ( Exception e ) { throw new RuntimeException( e ); } numRows = currentRow; return new KCell[] {}; } StaxPoiSheet( XSSFReader reader, String sheetName, String sheetID ); }
StaxPoiSheet implements KSheet { @Override public KCell[] getRow( int rownr ) { if ( rownr < 0 || rownr >= numRows ) { throw new ArrayIndexOutOfBoundsException( rownr ); } if ( rownr + 1 < firstRow ) { return new KCell[0]; } if ( rownr > 0 && currentRow == rownr + 1 ) { return currentRowCells; } try { if ( currentRow >= rownr + 1 ) { resetSheetReader(); } while ( sheetReader.hasNext() ) { int event = sheetReader.next(); if ( event == XMLStreamConstants.START_ELEMENT && sheetReader.getLocalName().equals( "row" ) ) { String rowIndicator = sheetReader.getAttributeValue( null, "r" ); currentRow = Integer.parseInt( rowIndicator ); if ( currentRow < rownr + 1 ) { continue; } currentRowCells = parseRow(); return currentRowCells; } } } catch ( Exception e ) { throw new RuntimeException( e ); } numRows = currentRow; return new KCell[] {}; } StaxPoiSheet( XSSFReader reader, String sheetName, String sheetID ); @Override KCell[] getRow( int rownr ); @Override String getName(); @Override int getRows(); @Override KCell getCell( int colnr, int rownr ); void close(); }
StaxPoiSheet implements KSheet { @Override public KCell[] getRow( int rownr ) { if ( rownr < 0 || rownr >= numRows ) { throw new ArrayIndexOutOfBoundsException( rownr ); } if ( rownr + 1 < firstRow ) { return new KCell[0]; } if ( rownr > 0 && currentRow == rownr + 1 ) { return currentRowCells; } try { if ( currentRow >= rownr + 1 ) { resetSheetReader(); } while ( sheetReader.hasNext() ) { int event = sheetReader.next(); if ( event == XMLStreamConstants.START_ELEMENT && sheetReader.getLocalName().equals( "row" ) ) { String rowIndicator = sheetReader.getAttributeValue( null, "r" ); currentRow = Integer.parseInt( rowIndicator ); if ( currentRow < rownr + 1 ) { continue; } currentRowCells = parseRow(); return currentRowCells; } } } catch ( Exception e ) { throw new RuntimeException( e ); } numRows = currentRow; return new KCell[] {}; } StaxPoiSheet( XSSFReader reader, String sheetName, String sheetID ); @Override KCell[] getRow( int rownr ); @Override String getName(); @Override int getRows(); @Override KCell getCell( int colnr, int rownr ); void close();  }