apache poi - java.lang.NumberFormatException: For input string: " " -
this question has answer here:
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
Post a Comment