国产探花免费观看_亚洲丰满少妇自慰呻吟_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();  }    }


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 嘉祥县| 茂名市| 庄浪县| 祁连县| 万山特区| 韩城市| 浦江县| 卢湾区| 额济纳旗| 大冶市| 曲阳县| 赞皇县| 交口县| 五华县| 扬中市| 河曲县| 彭水| 浦江县| 黄平县| 达州市| 岑巩县| 长白| 株洲县| 三江| 会理县| 出国| 宾川县| 阳朔县| 全椒县| 天祝| 梓潼县| 高州市| 卓资县| 张家界市| 宁波市| 靖西县| 靖安县| 靖西县| 浦城县| 浦城县| 丰台区|