@Test public void testCellMerge() throws Exception { ExcelParser parser = new ExcelParser((Map<String, List<DataListener>>) null); CellRangeAddress[] ranges = new CellRangeAddress[1]; Workbook workbook = new XSSFWorkbook(); Sheet sheet = workbook.createSheet(); Cell cell = sheet.createRow(2).createCell(2); ranges[0] = new CellRangeAddress(2, 7, 2, 5); cell.setCellValue(FIRST_CELL_CONTENT); cell = sheet.createRow(7).createCell(5); cell.setCellValue(LAST_CELL_VALUE); cell = sheet.createRow(1).createCell(1); assertNull(parser.getRangeIfMerged(cell, ranges)); cell = sheet.getRow(2).createCell(5); cell.setCellValue("wrong"); CellRangeAddress rangeIfMerged = parser.getRangeIfMerged(cell, ranges); assertEquals(FIRST_CELL_CONTENT, sheet.getRow(rangeIfMerged.getFirstRow()).getCell(rangeIfMerged.getFirstColumn()).getStringCellValue()); }
CellRangeAddress getRangeIfMerged( Cell cell, CellRangeAddress[] mergedRanges ) { for ( int i = 0; i < mergedRanges.length; i++ ) { CellRangeAddress r = mergedRanges[ i ]; if ( r.isInRange( cell.getRowIndex(), cell.getColumnIndex() ) ) { return r; } } return null; }
ExcelParser implements
        DecisionTableParser { CellRangeAddress getRangeIfMerged( Cell cell, CellRangeAddress[] mergedRanges ) { for ( int i = 0; i < mergedRanges.length; i++ ) { CellRangeAddress r = mergedRanges[ i ]; if ( r.isInRange( cell.getRowIndex(), cell.getColumnIndex() ) ) { return r; } } return null; } }
ExcelParser implements
        DecisionTableParser { CellRangeAddress getRangeIfMerged( Cell cell, CellRangeAddress[] mergedRanges ) { for ( int i = 0; i < mergedRanges.length; i++ ) { CellRangeAddress r = mergedRanges[ i ]; if ( r.isInRange( cell.getRowIndex(), cell.getColumnIndex() ) ) { return r; } } return null; } ExcelParser( final Map<String, List<DataListener>> sheetListeners );  ExcelParser( final List<DataListener> sheetListeners );  ExcelParser( final DataListener listener ); }
ExcelParser implements
        DecisionTableParser { CellRangeAddress getRangeIfMerged( Cell cell, CellRangeAddress[] mergedRanges ) { for ( int i = 0; i < mergedRanges.length; i++ ) { CellRangeAddress r = mergedRanges[ i ]; if ( r.isInRange( cell.getRowIndex(), cell.getColumnIndex() ) ) { return r; } } return null; } ExcelParser( final Map<String, List<DataListener>> sheetListeners );  ExcelParser( final List<DataListener> sheetListeners );  ExcelParser( final DataListener listener ); void parseFile( InputStream inStream ); void parseFile( File file ); void parseWorkbook( Workbook workbook ); void newCell( List<? extends DataListener> listeners,
                         int row,
                         int column,
                         String value,
                         int mergedColStart ); }
ExcelParser implements
        DecisionTableParser { CellRangeAddress getRangeIfMerged( Cell cell, CellRangeAddress[] mergedRanges ) { for ( int i = 0; i < mergedRanges.length; i++ ) { CellRangeAddress r = mergedRanges[ i ]; if ( r.isInRange( cell.getRowIndex(), cell.getColumnIndex() ) ) { return r; } } return null; } ExcelParser( final Map<String, List<DataListener>> sheetListeners );  ExcelParser( final List<DataListener> sheetListeners );  ExcelParser( final DataListener listener ); void parseFile( InputStream inStream ); void parseFile( File file ); void parseWorkbook( Workbook workbook ); void newCell( List<? extends DataListener> listeners,
                         int row,
                         int column,
                         String value,
                         int mergedColStart ); static final String DEFAULT_RULESHEET_NAME; }