how to get integer value from Ms Excel to java -
i imported apache.poi package , want integer value excel cell java console. know how string value excel cell java console
system.out.println(sh1.getrow(0).getcell(2).getrichstringcellvalue().tostring());
but don't know how integer value. please me.
the code below.
import java.io.fileoutputstream; import org.apache.poi.hssf.usermodel.hssfworkbook; import org.apache.poi.ss.usermodel.workbook; import org.apache.poi.ss.usermodel.sheet; import org.apache.poi.ss.util.workbookutil; import org.apache.poi.ss.usermodel.row; import org.apache.poi.ss.usermodel.cell; public class excel { public static void main(string[] arg){ workbook workbook = new hssfworkbook(); sheet sh1 = workbook.createsheet("sheet1"); cell cell1 = sh1.createrow(0).createcell(0); cell cell2 = sh1.createrow(0).createcell(1); cell cell3 = sh1.createrow(0).createcell(2); cell1.setcellvalue(100); cell2.setcellvalue(200); cell3.setcellformula("a1+b1"); //here!! want integer value of cell3 system.out.println(sh1.getrow(0).getcell(2).....); .......... } }
thanks
use function getnumericcellvalue()
. see documentation of hssfcell more information.
Comments
Post a Comment