@Test public void testNullDateCell() throws Exception { final String sheetId = "1"; final String sheetName = "Sheet 1"; XSSFReader reader = mockXSSFReader( sheetId, SHEET_DATE_NO_V, mockSharedStringsTable( "Some Date" ), mockStylesTable( Collections.singletonMap( 2, 165 ), Collections.singletonMap( 165, "M/D/YYYY" ) ) ); StaxPoiSheet spSheet = new StaxPoiSheet( reader, sheetName, sheetId ); KCell cell = spSheet.getRow( 1 )[0]; assertNotNull( cell ); assertEquals( KCellType.DATE, cell.getType() ); cell = spSheet.getRow( 2 )[0]; assertNull( "cell must be null", cell ); }
@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();  }