java用poi实现将数据库里面的数据导入已经存在的excel模板中。最好有实例参考,谢谢。

java用poi实现将数据库里面的数据导入已经存在的excel模板中。最好有实例参考,谢谢。,第1张

/**

     * 通过EXCEL模板导入团队信息

     */

    @ResponseBody

    @RequestMapping("importTemp")

    public Map<String,String> importTemp(HttpServletRequest request,HttpSession session,

              @RequestParam(value="excel", required=false) MultipartFile file, HttpServletResponse response ) {

        Yhb yhb=(Yhb)session.getAttribute(WebConstants.CURRENT_USER)

        String zjr = yhb.getYhid()

        List<DrTdb> tdxxList = new ArrayList<DrTdb>()

        Map<String,String> map = new HashMap<String,String>()

        String sfcg = "1"

        String bcghs = ""

        String bcgyy = ""

        HSSFWorkbook workbook = null

        try {

            workbook = new HSSFWorkbook(file.getInputStream())

            HSSFSheet sheet = workbook.getSheetAt(0)  

            if (sheet != null)  

            { 

              int d= sheet.getPhysicalNumberOfRows()

               other: for (int i = 7 i < sheet.getPhysicalNumberOfRows() i++)  

                {  

                    sfcg = "2"

                    HSSFRow row = sheet.getRow(i)  

                    DrTdb td = new DrTdb()

                    int rs = 1

                    //td.setTdbm("T"+DateUtil.CurrentTime("MM-dd"))

                    td.setZjr(zjr)

                    for (int j = 0 j < 8 j++)  

                    {  

                        HSSFCell cell = row.getCell(j)  

                        if(j == 0){

                            if(cell != null){

                  搜喊姿              String cellStr = cell.toString()  

                                if(isDigit(cellStr) != ""){

                                    String NDID = (String) tdglService.queryForObject("tdExcel.queryNd",isDigit(cellStr))

                                    td.setNd(NDID)

                                }else{

                                    sfcg = "0"

                                    bcghs = String.valueOf(i+1)

                                    bcgyy = "请填写正确的年度"

                                    break other

                                }

                            }else{

                                sfcg = "0"

                                bcghs = String.valueOf(i+1)

                                bcgyy = "年度不可为空"

                                break other

                            }

                        }else if(j == 1){

                            if(cell != null){

                                String cellStr = cell.toString()

                                String YXID = (String) tdglService.queryForObject("tdExcel.queryIdByYx",cellStr)

                                String YXDM = (String) tdglService.queryForObject("tdExcel.queryDmByYx",cellStr)

                                if(YXDM==null || YXDM==""){

                                    sfcg = "0"

                                    bcghs = String.valueOf(i+1)

                                    bcgyy = "院系不存在"

                                    break other

                                }

                                td.setSsyx(YXID)

                                //设置团队编码

                                String currentYear = DateUtil.CurrentTime("yyyy")//当前年份    

                                String  tdbm=""

                                String str=null

                                str="T"+currentYear+YXDM

                                String maxID = (String) tdglService.queryForObject("tdgl.queryMaxID", str)//当前团队最大ID

                                String str_q=   maxID.substring(1)

                                int  MAXID=Integer.parseInt(str_q) //将返回的字符串去掉T

                                tdbm="T"+(MAXID+1)

                 世绝             渗唯  td.setTdbm(tdbm)

                            }else{

                                sfcg = "0"

                                bcghs = String.valueOf(i+1)

                                bcgyy = "院系不存在"

                                break other

                            }

                        }else if(j == 3){

                            if(cell != null){

                                String cellStr = cell.toString()

                                String[] zdjs = cellStr.split(",")

                                for(int in = 0 in < zdjs.length in ++){

                                    zdjs[in] = zdjs[in].substring(1,zdjs[in].length()-1)

                                    //zdjs[in]=isDigit(zdjs[in])

                                    zdjs[in] = (String) tdglService.queryForObject("tdExcel.queryIdByZgh",zdjs[in])

                                    if("".equals(zdjs[in]) || zdjs[in] == null){

                                        sfcg = "0"

                                        bcghs = String.valueOf(i+1)

                                        bcgyy = "教师编号有误"

                                        break other

                                    }

                                }

                                td.setZdjs(zdjs)

                            }else{

                                sfcg = "0"

                                bcghs = String.valueOf(i+1)

                                bcgyy = "指导教师不可为空"

                                break other

                            }

                        }else if(j == 5){

                            if(cell != null){

                                String cellStr = cell.toString()

                                cellStr = cellStr.substring(1,cellStr.length()-1)

                                // BigDecimal bg=new BigDecimal(cellStr)

                                 //cellStr=bg.toPlainString()

                                cellStr = (String) tdglService.queryForObject("tdExcel.queryIdByXh",cellStr)

                                

                                if("".equals(cellStr) || cellStr == null){

                                    sfcg = "0"

                                    bcghs = String.valueOf(i+1)

                                    bcgyy = "团队组长学号有误"

                                    break other

                                }

                                else{

                                    String Tdid = (String) tdglService.queryForObject("tdExcel.queryryid",cellStr)

                                    String XM = (String) tdglService.queryForObject("tdExcel.queryXmBy",cellStr)

                                    if( Tdid!= null){

                                        sfcg = "0"

                                        bcghs = String.valueOf(i+1)

                                        bcgyy = "团队组长"+XM+"已存在"

                                        break other

                                    }

                                }

                                td.setTdzz(cellStr)

                            }else{

                                sfcg = "0"

                                bcghs = String.valueOf(i+1)

                                bcgyy = "团队组长不可为空"

                                break other

                            }

                        }else if(j == 7){

                            if(cell != null){

                                String cellStr = cell.toString()  

                                String[] tdzy = cellStr.split(",")

                                for(int k = 0 k < tdzy.length k++){

                                    tdzy[k] = tdzy[k].substring(1,tdzy[k].length()-1)

                                    tdzy[k] = (String) tdglService.queryForObject("tdExcel.queryIdByXh",tdzy[k])

                                    if("".equals(tdzy[k]) || tdzy[k] == null){

                                        sfcg = "0"

                                        bcghs = String.valueOf(i+1)

                                        bcgyy = "团队组员学号有误"

                                        break other

                                    }

                                    rs++

                                }

                                td.setTdzy(tdzy)

                            }else{

                                sfcg = "0"

                                bcghs = String.valueOf(i+1)

                                bcgyy = "团队组员不可为空"

                                break other

                            }

                        }

                    }  

                        td.setRs(String.valueOf(rs))

                        tdxxList.add(td)

                }  

            }  

        }catch(IOException e){

            e.printStackTrace()

        }

        if("2".equals(sfcg)){

            

            

            for(DrTdb tdxx : tdxxList){

                tdglService.insert("tdExcel.addTdxx", tdxx)

                tdglService.insert("tdExcel.addTdzz", tdxx)

                tdglService.insert("tdExcel.addTdzy", tdxx)

                tdglService.insert("tdExcel.addZdjs", tdxx)

            }

            

        }

        map.put("sfcg",sfcg )

        map.put("bcghs",bcghs )

        map.put("bcgyy",bcgyy )

        return map

    }

看不懂留言

将下载的插件压缩包解压至游戏安装目录下的Interface\Addons,如没有则自行新建。

首先在安装综合插件组的时候,玩家需要将插件安装包解压出的Interface文件夹放到魔兽根目录\ classic_文件夹内,覆盖原有Interface文件夹。

比如魔兽世界安装路径为"D:\Game\World of Warcraft”。那么Interface的位置为"D:\Game\World of Warcraft\ classic _\Interface"

如果是要安装单独的插件,那么插件必须安装在"D:\Game\World ofWarcraft\_ classic _\Interface/AddOns"文件夹内。

扩展资料

DBM插件的功能

1、DBM拥有同步系统,可精确的进行计时;

2、DBM模块化设计——所有的模块都可以单独的交换、删除以及更新;

3、DBM需求时载入——模块和图形界面都是单独的插件,它们会在需求的时候自动载入。如果你不打开设置窗口,图形界面不会占用任何资源;

4、DBM高效的代码——败嫌非常低的内存和CPU资源占用率;

5、醒目的警报——诸如屏幕闪烁或屏幕震动的特殊警报会在发生紧急祥枯碰事件时吸引您的注意;

6、DBM计时条可根据时间动态改变颜色,计时即将结束时计时条也会谨谈进行闪烁;

7、DBM多种可供选择的计时条外观,颜色也可以自定;

8、DBM可创建自定义计时器;

9、DBM可延长战斗记录侦测距离。


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/tougao/12287422.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-24
下一篇 2023-05-24

发表评论

登录后才能评论

评论列表(0条)

保存