Java excel - Comparing two strings -


i have check strings of 2 xlsx files if equal must return name, returns null, can me?

try     {         fileinputstream fiscod = new fileinputstream(pathc);          xssfworkbook wb = new xssfworkbook (fiscod);         xssfsheet sheet = wb.getsheetat(0);         int lastrow = sheet.getlastrownum();          for(int i=0; i<lastrow; i++)         {                   row row = sheet.getrow(i);             cell cell = row.getcell(jobcod);                string tmp = cell.getrichstringcellvalue().getstring().tolowercase();              if (tmp.equals(jobname)) //jobname string             {                 return tmp;             }             else             {                 return null;             }         }         fiscod.close();     }     catch (ioexception e)     {         system.out.println(e.getmessage());     } 

the first mismatch in above code cause null returned without checking subsequent row values. more likely, scenario describing.

check all cell values before resorting returning null when attempted match fails.

for (int = 0; < lastrow; i++) {     row row = sheet.getrow(i);     cell cell = row.getcell(jobcod);      string tmp = cell.getrichstringcellvalue().getstring().tolowercase();      if (tmp.equals(jobname)) {         return tmp;     } }  return null; // return null 

Comments

Popular posts from this blog

php - get table cell data from and place a copy in another table -

javascript - Mootools wait with Fx.Morph start -

php - Navigate throught databse rows -