excel - java.lang.NullPointerException error, using -
this question has answer here:
- what nullpointerexception, , how fix it? 12 answers
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
Post a Comment