IMPORT&NBSP;JXL. DATECELL;IMPORT&NBSP;JXL. numbercell;import org.apache.log4j.logger;import org.apache.poi.hssf.usermodel.hssfcell;import org.apache.poi.hssf.usermodel.hssfdateutil;import org.apache.poi.hssf.usermodel.hssfrow;import org.apache.poi.hssf.usermodel.hssfsheet;import org.apache.poi.hssf.usermodel.hssfworkbook;public String txttableimport (string tablename, string path, httpservletrequest request) { file datafile = new file (path); try { // Importing Excel Files FileInputStream is=new fileinputstream (datafile); hssfworkbook wbs = new Hssfworkbook (IS); hssfsheet childsheet = Wbs.getsheetat (0); int x = Childsheet.getlastrownUm (); // has X line for (int j=1; j<=x;j++ ) { hssfrow row = childsheet.getrow (j); int y = row.getlastcellnum () ; // has y column string name= globalfunc.tostring (Row.getCell (0)); //read the value of a column string age globalfunc.tostring (Row.getCell (1) ); //reads the value of a column } } catch (exception e) { e.printstacktrace (); return constants.uploadfail; //Import failed: Unknown error! } logger.debug ("data import successfully!"); return constants.uploadsuccess;//Import Success! &nbsP;}
Java POI Import into Excel