国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JSP > 正文

在JSP中將EXEL文件的數據傳入到數據庫中

2019-11-14 23:26:55
字體:
來源:轉載
供稿:網友
jsp中將EXEL文件的數據傳入到數據庫

在jsp中:

在script中使用函數:

$(function(){  //var lpyear = document.getElementById("lpyear").value; //var lpmonth = document.getElementById("lpmonth").value; //var factoryid = document.getElementById("factoryid").value; //var url = "&lpyear="+lpyear+"&factoryid="+factoryid+"&lpmonth="+lpmonth; $("#file").uploadify({  "height" : 19,  "buttonText" : "導入本月數據",  "buttonClass" : "btn",  "fileTypeDesc" : "Excel Files",  "fileTypeExts" : "*.xls",  "swf" : <select:link page="/Charts/uploadify.swf" />,  "uploader" : <select:link page="/Budgetimp.do?method=monthimp" />,//+url,  "onUploadStart" : function(file){   showWait("正在上傳"+file.name+",請稍候...");  },  "onUploadSuccess" : function(file, data, response) {   $('#' + file.id).find('.data').html(' 上傳完畢');   hideWait();  },  "onQueueComplete" : function(queueData) {   show();  } });});

在body中寫入:

<td style="text-align: center;width: 150px;padding-bottom: 1px;">               <input type="file" name="file" id="file">              </td>

java中:

//導入本月數據    @SupQQty="";                      //year=request.getParameter("lpyear");           //month=request.getParameter("lpmonth");           //factoryid=request.getParameter("factoryid");           Cell cell = sheet.getCell(0, i);//獲取第一列所有行的值           if(cell!=null && cell.getContents() != null){            year = cell.getContents().trim();           }           cell = sheet.getCell(1, i);           if(cell!=null && cell.getContents() != null){            month = cell.getContents().trim();           }           cell = sheet.getCell(2, i);           if(cell!=null && cell.getContents() != null){            factoryid = cell.getContents().trim();           }           cell = sheet.getCell(3, i);           if(cell!=null && cell.getContents() != null){             feename= cell.getContents().trim();           }           cell = sheet.getCell(4, i);           if(cell!=null && cell.getContents() != null){            monthqty = cell.getContents().trim();           }           cell = sheet.getCell(5, i);           if(cell!=null && cell.getContents() != null){            countqty = cell.getContents().trim();           }           cell = sheet.getCell(6, i);           if(cell!=null && cell.getContents() != null){            tqqty = cell.getContents().trim();           }                      if(!"".equals(year)&&!"".equals(month)&&!"".equals(factoryid)&&!"".equals(feename))             //&&!"".equals(sycomp_id)&&NumberUtils.isNumber(sycomp_id)&&!"".equals(tobasystid)&&NumberUtils.isNumber(factoryid)             //&&NumberUtils.isNumber(tobasystid)判斷字符串是否是數字             //&&!"".equals(monthqty)&&NumberUtils.isNumber(monthqty)&&Double.parseDouble(monthqty)>0             //&&!"".equals(countqty)&&NumberUtils.isNumber(countqty)&&Double.parseDouble(countqty)>0             //&&!"".equals(tqqty))&&NumberUtils.isNumber(tqqty)&&Double.parseDouble(tqqty)>0)             {                        if("".equals(monthqty)){monthqty="0";}            if("".equals(countqty)){countqty="0";}            if("".equals(tqqty)){tqqty="0";}            /*            Double monthqty1=Double.parseDouble(monthqty);            Double countqty1=Double.parseDouble(countqty);            Double tqqty1=Double.parseDouble(tqqty);            */            System.out.println(year+","+month+","+factoryid+","+feename+","+monthqty+","+countqty+","+tqqty);            /*            CallHelper helper =initializeCallHelper("G_logistisfeebymonth", form, request, false);                  helper.setParam("year", year);                  helper.setParam("month", month);                  helper.setParam("factoryid", factoryid);                  helper.setParam("feename", feename);                  helper.setParam("monthqty", monthqty);                  helper.setParam("countqty", countqty);                  helper.setParam("tqqty", tqqty);                  helper.setParam("personid", getPersonId(request));                  helper.execute();                                    StringBuffer exe = new StringBuffer();            exe.append("merge into l_logistisfeebymonth a ")             .append("using ( ")             .append("select * from table( ")             .append("values('2015','01','1','物流費用合計','5640.00','28333.00','26865.00') ")             .append(") as  tab(year,month,factoryid,feename,monthqty,countqty,tqqty) ")             .append(") b on a.year = b.year and a.month = b.month and a.factoryid = b.factoryid and a.feename = b.feename")             .append("when matched then ")             .append("update set a.monthqty = b.monthqty,a.countqty=b.countqty,a.tqqty=b.tqqty ")             .append("when not matched then ")             .append("insert (year,month,factoryid,feename,monthqty,countqty,tqqty,create_time,create_personid)")             .append("values(b.year,b.month,b.factoryid,b.feename,b.monthqty,b.countqty,b.tqqty,current timestamp,"+getPersonId(request)+")");            sqls.add(exe.toString());            */            String sql = "select year,month from l_logistisfeebymonth where year='"+year+"' and month='"+month+"' and factoryid='"+factoryid+"'";            Executer ex = new Executer();      SqlRuturn sp=ex.ExecSeletSQL(sql);      ArrayList<?> list = sp.getResultSet();      System.out.println(list.size());      if(list.size()==0){//判斷數據是否存在       StringBuffer exe = new StringBuffer();             exe.append("insert into l_logistisfeebymonth(year,month,factoryid,feename,monthqty,countqty,tqqty,create_time,create_personid) ")              .append("values('"+year+"','"+month+"','"+factoryid+"','"+feename+"','"+monthqty+"','"+countqty+"','"+tqqty+"',current timestamp,"+getPersonId(request)+")");             sqls.add(exe.toString());      }                        /*            StringBuffer exe1 = new StringBuffer();            exe1.append("merge into l_logistisfeebymonth a ")            .append("using ( ")            .append("select year,month,factoryid,feename,monthqty,countqty,tqqty from l_logistisfeebymonth_temp ")            .append(") b on a.year = b.year and a.month = b.month and a.factoryid = b.factoryid")            .append("when matched then ")            .append("update set a.status=to_char(int(a.status)+1) ")            .append("when not matched then ")            .append("insert (year,month,factoryid,feename,monthqty,countqty,tqqty,create_time,create_personid)")            .append("values(b.year,b.month,b.factoryid,b.feename,b.monthqty,b.countqty,b.tqqty,current timestamp,"+getPersonId(request)+")");            sqls.add(exe1.toString());             */                 }          }          //sqls.add("update l_logistisfeebymonth set month = '0'||trim(month) where length(trim(month)) < 2");          OptionUtil.exeSqls(sqls);         }     } catch (Exception e) {   e.printStackTrace();  }    }


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 长阳| 濉溪县| 色达县| 肇庆市| 新源县| 葫芦岛市| 合作市| 富源县| 微山县| 浠水县| 宝清县| 达拉特旗| 高邑县| 鄢陵县| 威远县| 龙泉市| 上饶市| 化州市| 竹北市| 扶余县| 容城县| 西宁市| 涪陵区| 东宁县| 左权县| 平利县| 聂拉木县| 莱阳市| 姚安县| 永新县| 清原| 青州市| 咸丰县| 巴中市| 张北县| 沁源县| 石河子市| 仪陇县| 青龙| 丹巴县| 五家渠市|