apache poi - java.lang.NumberFormatException: For input string: " " -


hello,all trying save excel sheet data mysql database. using apache poi. getting cell values using dataformatter in apache poi. getting cell values string format, trying change string value long getting numberformatexception. trying below code. please try solve problem.

thank you.

   fileinputstream inputstream = new fileinputstream(filename);    xssfworkbook workbook = new xssfworkbook(inputstream);     xssfsheet firstsheet = workbook.getsheetat(0);     dataformatter formatter = new dataformatter();     for(int z=0;z<firstsheet.getlastrownum();z++)     {     cell upccell=firstsheet.getrow(z).getcell(0);     string upcstring =formatter.formatcellvalue(upccell);     long upc=long.valueof(upcstring);     .     .     .     } 

this error stack trace in console.

java.lang.numberformatexception: input string: "upc" @ java.lang.numberformatexception.forinputstring(unknown source) @ java.lang.long.parselong(unknown source) @ java.lang.long.<init>(unknown source) 

i think cell value return code not numeric value.

cell upccell = firstsheet.getrow(z).getcell(0);

so have make sure whatever cell reading should contains numeric values.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -