日期:2014-05-16 浏览次数:20424 次
@SuppressWarnings("unchecked") public String uploadAlarmRmsJkmalfuncexperience() { String date = new SimpleDateFormat("yyyyMMddHHmmssSS").format(new Date()); ServletContext aplication = ServletActionContext.getServletContext(); String path = aplication.getRealPath("/excel"); System.out.println(path); FileUtil.copyFileToDir(path, upload, date+"_"+uploadFileName); try { InputStream is = new FileInputStream(new File(path,date+"_"+uploadFileName)); try { Workbook book= Workbook.getWorkbook(is); Sheet seet= book.getSheet(0); List<AlarmRmsJkmalfuncexperience> lists = new ArrayList(); AlarmRmsJkmalfuncexperience jkmalfuncexperience=null; for(int i=1;i<seet.getRows();i++) { jkmalfuncexperience =new AlarmRmsJkmalfuncexperience(); jkmalfuncexperience.setExpid(seet.getCell(0,i).getContents()); jkmalfuncexperience.setExptitle(seet.getCell(1,i).getContents()); jkmalfuncexperience.setMalfuncarea(seet.getCell(2,i).getContents()); jkmalfuncexperience.setSpecialtype(seet.getCell(3,i).getContents()); jkmalfuncexperience.setDevicetype(seet.getCell(4,i).getContents()); jkmalfuncexperience.setDevicecompany(seet.getCell(5,i).getContents()); jkmalfuncexperience.setVersion(seet.getCell(6,i).getContents()); jkmalfuncexperience.setExplevel(seet.getCell(7,i).getContents()); jkmalfuncexperience.setExpkeyword(seet.getCell(8,i).getContents()); jkmalfuncexperience.setMalfuncdescription(seet.getCell(9,i).getContents()); jkmalfuncexperience.setExperiencesummary(seet.getCell(10,i).getContents()); lists.add(jkmalfuncexperience); } alarmRmsJkmalfuncexperienceManager.saveOrUpdateAll(lists); } catch (BiffException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } return SUCCESS; }?