Summary: | CellIterator Skips First Column | ||
---|---|---|---|
Product: | POI | Reporter: | Danny Brain <apache> |
Component: | HSSF | Assignee: | POI Developers List <dev> |
Status: | RESOLVED FIXED | ||
Severity: | normal | Keywords: | PatchAvailable |
Priority: | P2 | ||
Version: | 3.0-dev | ||
Target Milestone: | --- | ||
Hardware: | All | ||
OS: | other |
Description
Danny Brain
2006-08-18 13:58:44 UTC
Good catch. Keep it up. Applied to Svn. Feel free in inspect and comment if reuqired. Jason This bug is still in the 3.0-alpha2-20060616 I've also experienced this behavior. Attaching a code snippet: private String extractExcel( InputStream stream ) throws IOException { HashSet set = new HashSet(); HSSFWorkbook workbook = new HSSFWorkbook(stream); int sheetCount = workbook.getNumberOfSheets(); int resultLength = 0; for( int i = 0 ; i < sheetCount ; i++ ) { //System.out.println( "Reading sheet #" + (i+1) ); HSSFSheet at = workbook.getSheetAt( i ); int rowCount = at.getPhysicalNumberOfRows(); for (int j = 0; i< rowCount; j++) { //System.out.println( "Reading row #" + (j+1) ); HSSFRow row = at.getRow( j ); if (row == null) break; for( Iterator iterator = row.cellIterator(); iterator.hasNext(); ) { HSSFCell cell = (HSSFCell)iterator.next(); if( cell.getCellType() == HSSFCell.CELL_TYPE_STRING ) { String string = cell.getRichStringCellValue().getString(); if( string != null && string.length() > 0 ) { if (set.add( string )) { resultLength += string.length(); resultLength++; } } } } } } StringBuffer result = new StringBuffer(resultLength); for( Iterator iterator = set.iterator(); iterator.hasNext(); ) { result.append( (String)iterator.next() ).append( ' '); } return result.toString(); } Works as of 12Jan2007, Testcase added. http://issues.apache.org/bugzilla/show_bug.cgi?id=41366 Please verify! |