excel - java.lang.NullPointerException error, using -


this question has answer here:

i'm writing code finds desired column in input sheet , takes entire column , put in different order in output sheet. want take in excel file , reorganize in output file. path i've chosen find numerical value of column , use find cells within each row. i'm getting error @ line rdrcell = inputsheet.getrow(placerow+1).getcell(y); there wrong way i'm trying cell value?

for(iterator<cell> cit = idrow.celliterator(); cit.hasnext(); )             {                 cell cell = cit.next();                 cell.setcelltype(cell.cell_type_string);                 string chr = "chr";                 row rdrrow = null;                 cell rdrcell = null;                 if(chr.equals(cell.getstringcellvalue()))                 {                     int y = cell.getcolumnindex();                     for(int placerow = 0; placerow<=rowcounter;placerow++)                     {                         // error in line below                         rdrcell = inputsheet.getrow(placerow+1).getcell(y);                         rdrcell.setcelltype(cell.cell_type_string);                         string chrstring = rdrcell.getstringcellvalue();                         cell chrcell = outputsheet.createrow(placerow).createcell(0);                         chrcell.setcellvalue(chrstring);                     }                  } 

your loop goes far.

for(int placerow = 0; placerow<=rowcounter;placerow++) 

change middle part , check placerow < rowcounter instead of <=


Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -