You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Birendar Waldiya <bw...@cisco.com> on 2006/05/26 15:32:17 UTC

The POI reading from cell 0 and suddenly jumps to cell 1

Hello Guys, 

I am using POI apis for reading the excel file, initially the data is read
from cell 0 for first 15 rows and then it start reading from cell 1, as a
result of which my my array size gets affected  and getting array out of
bound exception.
This is not happening for all the files but yes for two of my file it
haapening , did any one ever had such kind of problem ? What could be the
reason . 
Pasting the code that is reading the XLS files:-

Thanks 
Regards 
Birendar S Waldiya 

<code>
		 for (int i=0; i<numOfSheets; i++) {
	
		     HSSFSheet sheet = wb.getSheetAt (i);

			 int  phyRows = sheet.getPhysicalNumberOfRows();
		    
		   //  CCF.logInfo("PHYSICAL ROWS PROCESSES IN XLS FILE
:"+phyRows);
	   
			 for (Iterator rows = sheet.rowIterator();
rows.hasNext(); ) {
			    
				 HSSFRow row = (HSSFRow) rows.next ();
    			 
				 short c1 = row.getFirstCellNum();
				 short c2 = row.getLastCellNum();
	
					 String entries[] = new
String[c2-c1];
				 
			            for (short c=c1; c<c2; c++) { 
			                HSSFCell cell = row.getCell(c);
			                String cellValue = getCellValue
(cell);
			                  if(currentLine_==0)cellValue =
CheckForISOStdHeading(cellValue);
	
entries[c]=cellValue;  
			                }
			
			               try{
			                	if (entries != null){
	
if(isRowEmpty(entries)) break ;
	
routine.processRow(entries, currentLine_);
			                	 }else if(currentLine_==0 &&
isRowEmpty(entries)) {
					               throw new
XLSParserException(XLSParserException.XLS_PARSE_FIRST_LINE_EMPTY);
								 }else{
								    done =
true;
								 }
							} catch(Exception
e){
					    		e.printStackTrace();
							}
							currentLine_++;
						  rows.remove();
		    			}
           wb.removeSheetAt(i);
		   }
		  done = true;
		 
      } catch (IOException e) {
          e.printStackTrace();
      }
      
	   finally {
				
				routine.readCompleted(done);
				try {
				     close();
				}catch (IOException io_e)
{System.out.println(io_e);}
			}
		}

</code>

---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/