java - What is wrong with this cycle. HSSF -


enter image description here

in code i'm searching list of lists element, contains in list. why when found needed elements, it's starting work bad. if find element, contains in list, cell should fill in blue color, not happens.

 hssfworkbook workbook = new hssfworkbook(file);         creationhelper createhelper = workbook.getcreationhelper();         //get first sheet workbook         hssfsheet sheet = workbook.getsheetat(0);         cellstyle style = workbook.createcellstyle();         style.setfillforegroundcolor(indexedcolors.lime.getindex());         style.setfillpattern(cellstyle.solid_foreground);         cellstyle style2 = workbook.createcellstyle();         style2.setfillforegroundcolor(indexedcolors.red.getindex());         style2.setfillpattern(cellstyle.solid_foreground);         cellstyle style3 = workbook.createcellstyle();         style3.setfillforegroundcolor(indexedcolors.blue.getindex());         style3.setfillpattern(cellstyle.solid_foreground);      (int i=0;i<listoflist.size();i++)                      {         int count=0;         label1:         (int j=0;j<listoflist.get(i).size();j++) {             row row = sheet.getrow(i);             (int k=0;k<list.size();k++){                 if (list.get(k).equals(listoflist.get(i).get(j))) {                     count++;                     if (count==1) {                         system.out.println("("+list.get(k)+") asu <--> ("+listoflist.get(i).get(j)+") rzs "+"string: "+i+" column: "+j);                         row.createcell(2+j).setcellvalue(listoflist.get(i).get(j));                         row.getcell(2+j).setcellstyle(style);                         row row2 = sheet.getrow(k);                         row2.createcell(0).setcellvalue(list.get(k));                         row2.getcell(0).setcellstyle(style);                         continue label1;     }                     else{                     // count!=1                         system.out.println("another element contain!");                         row.createcell(2+j).setcellvalue(listoflist.get(i).get(j));                         row.getcell(2+j).setcellstyle(style3);}                  }                 else {row.createcell(2+j).setcellvalue(listoflist.get(i).get(j));                     row.getcell(2+j).setcellstyle(style2);}             }                                                      }                                                                  } 

the result now:

(222) asu <--> (222) rzs string: 0 column: 1 element contain! element contain! element contain! (233) asu <--> (233) rzs string: 1 column: 1 (244) asu <--> (244) rzs string: 2 column: 1 element contain! element contain! element contain! element contain! 

why not filled in blue????

found problem.

 else{                     // count!=1                 system.out.println("another element contain!");                 row.createcell(2+j).setcellvalue(listoflist.get(i).get(j));                 row.getcell(2+j).setcellstyle(style3);}          }         else {row.createcell(2+j).setcellvalue(listoflist.get(i).get(j));             row.getcell(2+j).setcellstyle(style2);} 

the 2nd else overwrite 1st else, pitty(


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -