标签:ssh框架 seda ++ response ddr exception NPU out 获取值
JAVA中EXLS导入功能实现 - 代码:
基于SSH框架下导入的流程及解析:
private File file; public synchronized File getFile() { return file; } public synchronized void setFile(File file) { this.file = file; }
/** * 导入exls 并解析 * @throws Exception */ public void inputfile() throws Exception{ String text = (String) super.getRequest().getParameter("text"); int flowid= 1415415;//(String)super.getRequest().getParameter("flowid"); System.out.println("text>>"+text); System.out.println("files>>"+file); try { FileInputStream fs = new FileInputStream(file); // 初始化一个工作簿 HSSFWorkbook hwb = new HSSFWorkbook(fs); // 第一张表单 HSSFSheet sheet = hwb.getSheetAt(0); HSSFRow row = null; int q=0; //遍历改行所有的行,j表示行数 getPhysicalNumberOfRows()表示得到行的总数 for (int j = 1; j < sheet.getPhysicalNumberOfRows(); j++) { row = sheet.getRow(j); //获取当前页 sheet = hwb.getSheetAt(0); // 获取首行属性名 HSSFRow rows = sheet.getRow(0); String sql ="(rms.int_id.nextval,"; String keysql="(int_id,"; //遍历所有值 for(int f=0;f<row.getLastCellNum();f++){ String stringkey =String.valueOf( rows.getCell(f).getRichStringCellValue()); //获取属性英文名 String key=queryDataService.queryatr(stringkey,text); keysql +=""+key+","; String state=queryDataService.getAttributestate(text,key); //获取值 String value =String.valueOf( row.getCell(f).getRichStringCellValue()); //判断数据类型拼装sql if(("integer").equals(state)){ sql +=""+value+","; }else if(("datetosecond").equals(state)){ value=value.substring(0,value.length()-2); sql +="to_date(‘"+value+"‘,‘yyyy-mm-dd hh24:mi:ss‘),"; }else{ sql +="‘"+value+"‘,"; } } keysql=keysql.substring(0,keysql.length()-1); keysql +=")"; sql=sql.substring(0,sql.length()-1); sql +=")"; String addSql=""+keysql+" values "+sql+""; q=queryDataService.addReviseData(addSql, text); } if(q>0){ super.getResponse().setHeader("Content-type", "text/html;charset=UTF-8"); super.getResponse().getWriter().write("{\"success\":true}"); }else{ super.getResponse().setHeader("Content-type", "text/html;charset=UTF-8"); super.getResponse().getWriter().write("{\"success\":false}"); } } catch (Exception e) { e.printStackTrace(); super.getResponse().setHeader("Content-type", "text/html;charset=UTF-8"); super.getResponse().getWriter().write("{\"success\":false}"); } }
标签:ssh框架 seda ++ response ddr exception NPU out 获取值
原文地址:https://www.cnblogs.com/ggq94/p/9732697.html