/*** 解析Excel里面的数据** @param wb* @return*/private String readExcelValue(Workbook wb, File tempFile) throws ParseException {//错误信息接收器String errorMsg = "";//得到第一个shellSheet sheet = wb.getSheetAt(0);//得到Excel的行数int totalRows = sheet.getPhysicalNumberOfRows();//总列数int totalCells = 0;//得到Excel的列数(前提是有行数),从第二行算起if (totalRows >= 2 && sheet.getRow(1) != null) {totalCells = sheet.getRow(0).getPhysicalNumberOfCells();}List<CustomerDO> userKnowledgeBaseList = new ArrayList<>();CustomerDO tempUserKB = null;AddressDO addressDO = null;String br = "<br/>";//循环Excel行数,从第二行开始。标题不入库for (int r = 1; r < totalRows; r++) {String rowMessage = "";Row row = sheet.getRow(r);if (row == null) {errorMsg += br + "第" + (r + 1) + "行数据有问题,请仔细检查!";continue;}tempUserKB = new CustomerDO();//地址idString id = "";//国家String countryid = "";//省份String provinceid = "";//城市String cityid = "";//地址String addressid = "";String countryName;String provinceName;String cityName;String addressName;//乡镇String township = "";//村组String village = "";//详细地址String address = "";//客户类别String hzkhtypeid = "";//具体类型String jtlxid = "";String hzjtlx = "";//客户名称String name = "";//一级名称String first_name = "";//二级名称String second_name = "";//三级名称String third_name = "";//网址String website = "";//公众号名称String official_account_name = "";//小程序String applet_name = "";//联系人String contacts = "";//职位String position = "";//性别String sex = "";//出生日期String birthday = "";//籍贯String natives = "";//民族String nation = "";//学历String education = "";//职称String title = "";//婚姻状况String marital = "";//兴趣爱好String hobby = "";//潜在商机String potential = "";//信息来源String source = "";
//            社会资源String sources = "";//qqString qq = "";//微信String wechat = "";//手机String phone = "";//电话String telphone = "";//邮箱String email = "";//传真String fax = "";//合作类型idString khhztypeid = "";//合作具体类型idString hzjtlxid = "";//具体项目名称String hzjtlxnameid = "";//String remarks = "";String khhztypeName = "";String hzjtlxName = "";//String hzjtlxnameName = "";//String hzkhtypeName = "";
//            、、初次见面String first_time = "";
//            是否合作过String cooperation = "";//最后一次见面String last_time = "";
//            合作意向String intention = "";//合作内容String content = "";//合作金额String money = "";//合作日期String date = "";//创建人String create_by = "";//创建时间String create_date = "";//标记String enabled_flag = "";//确认状态(0,未确认,1.确认)String confirm_status="";for (int c = 0; c < totalCells; c++) {Cell cell = row.getCell(c);
//循环Excel的行if (null != cell) {//cell.setCellType(CellType.STRING);
//                    if (c == 0) {//                        id = cell.getStringCellValue();
//                        if (StringUtils.isEmpty(id)) {//                            rowMessage += "班级id不能为空";
//                        } else if (id.length() > 100) {//                            rowMessage += "班级id的长度不能超过10";
//                        }
//                        tempUserKB.setId(Integer.valueOf(id));
//
//                    } elseif (c == 0) {countryid = cell.getStringCellValue();if (StringUtils.isEmpty(countryid)) {rowMessage += "国家ID不能为空";} else if (countryid.length() > 11) {rowMessage += "国家ID长度不能超过11";}//                        第一种方法取值(每次都要查询数据库,效率不高)
//                        Map<String, Object> map = new HashMap<>();
//                        map.put("name", countryid);
//
//                        List<AddressDO> list = commonService.listAddress(map);
//                        if (list.size() > 0) {//                            for (AddressDO addDO : list) {//                                countryid = Integer.toString(addDO.getId());
//                            }
//                        }
//
//                        tempUserKB.setCountryid(Integer.valueOf(countryid));String s = FieldDictUtil.get("khsjgl", "kh_customer", "countryid", countryid);System.out.println(s);
//                       第二种方法从缓存获取值   appid 数据库索引值  kh_customer需要使用的数据库  countryid使用的数据库的字段名  要从缓存获取的id值tempUserKB.setCountryid(Integer.valueOf(s));} else if (c == 1) {provinceid = cell.getStringCellValue();if (StringUtils.isEmpty(provinceid)) {rowMessage += "省份ID不能为空";} else if (provinceid.length() > 11) {rowMessage += "省份ID长度不能超过11";}
//                        Map<String, Object> map = new HashMap<>();
//                        map.put("name", provinceid);
//
//                        List<AddressDO> list = commonService.listAddress(map);
//                        if (list.size() > 0) {//                            for (AddressDO addDO : list) {//                                provinceid = Integer.toString(addDO.getId());
//                            }
//                        }
//                        tempUserKB.setProvinceid(Integer.valueOf(provinceid));tempUserKB.setProvinceid(Integer.valueOf(FieldDictUtil.get("khsjgl", "kh_customer", "provinceid", provinceid)));} else if (c == 2) {cityid = cell.getStringCellValue();if (StringUtils.isEmpty(cityid)) {rowMessage += "市县ID不能为空";} else if (cityid.length() > 11) {rowMessage += "市县ID不能超过11";}//                        Map<String, Object> map = new HashMap<>();
//                        map.put("name", cityid);
//
//                        List<AddressDO> list = commonService.listAddress(map);
//                        if (list.size() > 0) {//                            for (AddressDO addDO : list) {//                                cityid = Integer.toString(addDO.getId());
//                            }
//                        }//                        tempUserKB.setCityid(Integer.valueOf(cityid));tempUserKB.setCityid(Integer.valueOf(FieldDictUtil.get("khsjgl", "kh_customer", "cityid", cityid)));} else if (c == 3) {addressid = cell.getStringCellValue();if (StringUtils.isEmpty(addressid)) {rowMessage += "市县ID不能为空;";} else if (addressid.length() > 11) {rowMessage += "市县ID长度不能超过11;";}//                        tempUserKB.setAddressid(Integer.valueOf(addressid));tempUserKB.setAddress(FieldDictUtil.get("khsjgl", "kh_customer", "addressid", addressid));}
//                    else if (c == 4) {//                        township = cell.getStringCellValue();
//                        if (StringUtils.isEmpty(township)) {//                            rowMessage += "乡镇不能为空;";
//                        } else if (township.length() > 100) {//                            rowMessage += "乡镇长度长度不能超过100";
//                        }
//
//                        Map<String, Object> map = new HashMap<>();
//                        map.put("name", township);
//
//                        List<AddressDO> list = commonService.listAddress(map);
//                        if (list.size() > 0) {//                            for (AddressDO addDO : list) {//                                township = Integer.toString(addDO.getId());
//                            }
//                        }
//
//                        tempUserKB.setTownship(township);
//
//                    }//                    else if (c == 5) {//                        hzjtlx = cell.getStringCellValue();
//                        if (StringUtils.isEmpty(hzjtlx)) {//                            rowMessage += "类别不能为空;";
//                        } else if (hzjtlx.length() > 240) {//                            rowMessage += "类别有误;";
//                        }
//                        List<String> list = new ArrayList<>();
//
//                        String[] split = hzjtlx.split(",");
//                        for (int i = 0; i <split.length; i++) {//                            list.add(split[i]);
//                        }
//
                        传值
//                        Map<String, Object> map = new HashMap<>();
//                        map.put("list", list);
//
//                        List<HzjtlxDO> listDo = hzjtlxService.selectId(map);
//
//                        if (listDo.size() > 0) {//                            for (HzjtlxDO hzjtlxDO2 : listDo) {//                                hzjtlxid = String.valueOf(hzjtlxDO2.getId())+","+hzjtlxid;
//                            }
//                        }
//
//                        tempUserKB.setHzjtlxid(hzjtlxid);
//                    }
//
//                    }else if (c == 4) {township = cell.getStringCellValue();if (StringUtils.isEmpty(township)) {rowMessage += "具体地址不能为空;";} else if (township.length() > 100) {rowMessage += "具体地址长度不能超过100";}
//                        tempUserKB.setTownship(township);tempUserKB.setTownship(FieldDictUtil.get("khsjgl", "kh_customer", "township", township));} else if (c == 5) {village = cell.getStringCellValue();if (StringUtils.isEmpty(village)) {rowMessage += "village不能为空;";} else if (village.length() > 100) {rowMessage += "village长度不能超过100;";}
//                        tempUserKB.setVillage(village);tempUserKB.setVillage(FieldDictUtil.get("khsjgl", "kh_customer", "village", village));} else if (c == 6) {address = cell.getStringCellValue();if (StringUtils.isEmpty(address)) {rowMessage += "详细地址不能为空;";} else if (address.length() > 200) {rowMessage += "详细地址长度不能超过200;";}
//                        tempUserKB.setAddress(address);tempUserKB.setAddress(FieldDictUtil.get("khsjgl", "kh_customer", "address", address));} else if (c == 7) {hzkhtypeid = cell.getStringCellValue();if (StringUtils.isEmpty(hzkhtypeid)) {rowMessage += "客户类别不能为空;";} else if (hzkhtypeid.length() > 11) {rowMessage += "客户类别长度不能超过11;";}
//                        tempUserKB.setHzkhtypeid(Integer.valueOf(hzkhtypeid));tempUserKB.setHzkhtypeid(Integer.valueOf(FieldDictUtil.get("khsjgl", "kh_customer", "hzkhtypeid", hzkhtypeid)));} else if (c == 8) {jtlxid = cell.getStringCellValue();if (StringUtils.isEmpty(jtlxid)) {rowMessage += "具体类型不能为空;";} else if (jtlxid.length() > 11) {rowMessage += "具体类型长度不能超过11";}
//                        tempUserKB.setJtlxid(Integer.valueOf(jtlxid));tempUserKB.setJtlxid(Integer.valueOf(FieldDictUtil.get("khsjgl", "kh_customer", "jtlxid", jtlxid)));} else if (c == 9) {name = cell.getStringCellValue();if (StringUtils.isEmpty(name)) {rowMessage += "客户名称不能为空;";} else if (name.length() > 200) {rowMessage += "客户名称长度不能超过200";}
//                        tempUserKB.setName(name);tempUserKB.setName(FieldDictUtil.get("khsjgl", "kh_customer", "name", name));} else if (c == 10) {first_name = cell.getStringCellValue();if (StringUtils.isEmpty(first_name)) {rowMessage += "一级名称不能为空;";} else if (first_name.length() > 200) {rowMessage += "一级名称长度不能超过200;";}
//                        tempUserKB.setFirstName(first_name);tempUserKB.setFirstName(FieldDictUtil.get("khsjgl", "kh_customer", "first_name", first_name));} else if (c == 11) {second_name = cell.getStringCellValue();if (StringUtils.isEmpty(second_name)) {rowMessage += "二级名称不能为空;";} else if (second_name.length() > 200) {rowMessage += "二级名称长度不能超过200;";}
//                        tempUserKB.setSecondName(second_name);tempUserKB.setSecondName(FieldDictUtil.get("khsjgl", "kh_customer", "second_name", second_name));} else if (c == 12) {third_name = cell.getStringCellValue();if (StringUtils.isEmpty(third_name)) {rowMessage += "三级名称不能为空;";} else if (third_name.length() > 200) {rowMessage += "三级名称长度不能超过200;";}
//                        tempUserKB.setThirdName(third_name);tempUserKB.setThirdName(FieldDictUtil.get("khsjgl", "kh_customer", "third_name", third_name));} else if (c == 13) {website = cell.getStringCellValue();if (StringUtils.isEmpty(website)) {rowMessage += "网址不能为空;";} else if (website.length() > 100) {rowMessage += "网址长度不能超过100;";}
//                        tempUserKB.setWebsite(website);tempUserKB.setWebsite(FieldDictUtil.get("khsjgl", "kh_customer", "website", website));} else if (c == 14) {official_account_name = cell.getStringCellValue();if (StringUtils.isEmpty(official_account_name)) {rowMessage += "公众号名称不能为空;";} else if (official_account_name.length() > 200) {rowMessage += "公众号名称长度不能超过200;";}
//                        tempUserKB.setOfficialAccountName(official_account_name);tempUserKB.setOfficialAccountName(FieldDictUtil.get("khsjgl", "kh_customer", "official_account_name", official_account_name));} else if (c == 15) {applet_name = cell.getStringCellValue();if (StringUtils.isEmpty(applet_name)) {rowMessage += "小程序不能为空;";} else if (applet_name.length() > 200) {rowMessage += "小程序长度不能超过200;";}
//                        tempUserKB.setAppletName(applet_name);tempUserKB.setAppletName(FieldDictUtil.get("khsjgl", "kh_customer", "applet_name", applet_name));} else if (c == 16) {contacts = cell.getStringCellValue();if (StringUtils.isEmpty(contacts)) {rowMessage += "联系人不能为空;";} else if (contacts.length() > 200) {rowMessage += "联系人长度不能超过200;";}
//                        tempUserKB.setContacts(contacts);tempUserKB.setContacts(FieldDictUtil.get("khsjgl", "kh_customer", "contacts", contacts));} else if (c == 17) {position = cell.getStringCellValue();if (StringUtils.isEmpty(position)) {rowMessage += "职位不能为空;";} else if (position.length() > 100) {rowMessage += "职位长度不能超过100;";}
//                        tempUserKB.setPosition(position);tempUserKB.setPosition(FieldDictUtil.get("khsjgl", "kh_customer", "position", position));} else if (c == 18) {sex = cell.getStringCellValue();if (StringUtils.isEmpty(sex)) {rowMessage += "性别不能为空;";} else if (sex.length() > 2) {rowMessage += "性别长度不能超过2;";}
//                        String s = FieldDictUtil.get("khsjgl", "sys_worker", "gender", sex);
//                        System.out.println(s);tempUserKB.setSex(FieldDictUtil.get("khsjgl", "sys_worker", "sex", sex));} else if (c == 19) {birthday = cell.getStringCellValue();if (StringUtils.isEmpty(birthday)) {rowMessage += "生日不能为空;";} else if (birthday.length() > 40) {rowMessage += "生日长度不能超过40;";}
//                        tempUserKB.setBirthday(new SimpleDateFormat().parse(birthday));tempUserKB.setBirthday(new SimpleDateFormat().parse(FieldDictUtil.get("khsjgl", "kh_customer", "birthday", birthday)));} else if (c == 20) {natives = cell.getStringCellValue();if (StringUtils.isEmpty(natives)) {rowMessage += "籍贯不能为空;";} else if (natives.length() > 240) {rowMessage += "籍贯长度不能超过24;";}
//                        tempUserKB.setNatives(natives);tempUserKB.setNatives(FieldDictUtil.get("khsjgl", "kh_customer", "natives", natives));} else if (c == 21) {nation = cell.getStringCellValue();if (StringUtils.isEmpty(nation)) {rowMessage += "民族不能为空;";} else if (nation.length() > 240) {rowMessage += "民族长度不能超过24;";}
//                        tempUserKB.setNation(nation);tempUserKB.setNation(FieldDictUtil.get("khsjgl", "kh_customer", "nation", nation));} else if (c == 22) {education = cell.getStringCellValue();if (StringUtils.isEmpty(education)) {rowMessage += "学历不能为空;";} else if (education.length() > 240) {rowMessage += "学历长度不能超过24;";}
//                        tempUserKB.setEducation(education);tempUserKB.setEducation(FieldDictUtil.get("khsjgl", "kh_customer", "education", education));} else if (c == 23) {title = cell.getStringCellValue();if (StringUtils.isEmpty(title)) {rowMessage += "职称不能为空;";} else if (title.length() > 240) {rowMessage += "职称长度不能超过24;";}
//                        tempUserKB.setTitle(title);tempUserKB.setTitle(FieldDictUtil.get("khsjgl", "kh_customer", "title", title));} else if (c == 24) {marital = cell.getStringCellValue();if (StringUtils.isEmpty(marital)) {rowMessage += "婚姻状况不能为空;";} else if (marital.length() > 240) {rowMessage += "婚姻状况长度不能超过24;";}
//                        tempUserKB.setMarital(marital);tempUserKB.setMarital(FieldDictUtil.get("khsjgl", "kh_customer", "marital", marital));} else if (c == 25) {hobby = cell.getStringCellValue();if (StringUtils.isEmpty(hobby)) {rowMessage += "爱好不能为空;";} else if (hobby.length() > 240) {rowMessage += "爱好不能超过24;";}
//                        tempUserKB.setHobby(hobby);tempUserKB.setHobby(FieldDictUtil.get("khsjgl", "kh_customer", "hobby", hobby));} else if (c == 27) {potential = cell.getStringCellValue();if (StringUtils.isEmpty(potential)) {rowMessage += "潜在商机不能为空;";} else if (potential.length() > 240) {rowMessage += "潜在商机长度不能超过24;";}
//                        tempUserKB.setPotential(potential);tempUserKB.setPotential(FieldDictUtil.get("khsjgl", "kh_customer", "potential", potential));} else if (c == 28) {source = cell.getStringCellValue();if (StringUtils.isEmpty(source)) {rowMessage += "信息来源不能为空;";} else if (source.length() > 240) {rowMessage += "信息来源长度不能超过24;";}
//                        tempUserKB.setSource(source);tempUserKB.setSource(FieldDictUtil.get("khsjgl", "kh_customer", "source", source));} else if (c == 29) {qq = cell.getStringCellValue();if (StringUtils.isEmpty(qq)) {rowMessage += "qq不能为空;";} else if (qq.length() > 240) {rowMessage += "qq长度不能超过24;";}
//                        tempUserKB.setQq(qq);tempUserKB.setQq(FieldDictUtil.get("khsjgl", "kh_customer", "qq", qq));} else if (c == 30) {wechat = cell.getStringCellValue();if (StringUtils.isEmpty(wechat)) {rowMessage += "微信不能为空;";} else if (wechat.length() > 240) {rowMessage += "微信长度不能超过24;";}
//                        tempUserKB.setWechat(wechat);tempUserKB.setWechat(FieldDictUtil.get("khsjgl", "kh_customer", "wechat", wechat));} else if (c == 31) {phone = cell.getStringCellValue();if (StringUtils.isEmpty(phone)) {rowMessage += "手机不能为空;";} else if (phone.length() > 240) {rowMessage += "手机长度不能超过24;";}
//                        tempUserKB.setPhone(phone);tempUserKB.setPhone(FieldDictUtil.get("khsjgl", "kh_customer", "phone", phone));} else if (c == 32) {telphone = cell.getStringCellValue();if (StringUtils.isEmpty(telphone)) {rowMessage += "telphone不能为空;";} else if (email.length() > 240) {rowMessage += "telphone长度不能超过24;";}//                    List<CustomerDO> list = customerDao.selectId(userKnowledgeBaseList);
//
//                    if (list.size() > 0) {//                        for (CustomerDO Customer : list) {//                            hobby += Customer.getId()  ;
//                        }
//                    }//                        tempUserKB.setTelphone(telphone);tempUserKB.setTelphone(FieldDictUtil.get("khsjgl", "kh_customer", "telphone", telphone));} else if (c == 33) {email = cell.getStringCellValue();if (StringUtils.isEmpty(email)) {rowMessage += "邮箱不能为空;";} else if (email.length() > 240) {rowMessage += "邮箱长度不能超过24;";}
//                        tempUserKB.setEmail(email);tempUserKB.setEmail(FieldDictUtil.get("khsjgl", "kh_customer", "email", email));} else if (c == 34) {fax = cell.getStringCellValue();if (StringUtils.isEmpty(fax)) {rowMessage += "传真不能为空;";} else if (source.length() > 240) {rowMessage += "传真长度不能超过24;";}
//                        tempUserKB.setFax(fax);tempUserKB.setFax(FieldDictUtil.get("khsjgl", "kh_customer", "fax", fax));} else if (c == 35) {khhztypeid = cell.getStringCellValue();if (StringUtils.isEmpty(khhztypeid)) {rowMessage += "合作类型id不能为空;";} else if (khhztypeid.length() > 240) {rowMessage += "合作类型id长度不能超过24;";}
//                        tempUserKB.setKhhztypeid(khhztypeid);tempUserKB.setKhhztypeid(FieldDictUtil.get("khsjgl", "kh_customer", "khhztypeid", khhztypeid));} else if (c == 36) {hzjtlxid = cell.getStringCellValue();if (StringUtils.isEmpty(hzjtlxid)) {rowMessage += "合作具体类型id不能为空;";} else if (hzjtlxid.length() > 240) {rowMessage += "合作具体类型id长度不能超过24;";}
//                        tempUserKB.setHzjtlxid(hzjtlxid);tempUserKB.setHzjtlxid(FieldDictUtil.get("khsjgl", "kh_customer", "hzjtlxid", hzjtlxid));} else if (c == 37) {hzjtlxnameid = cell.getStringCellValue();if (StringUtils.isEmpty(hzjtlxnameid)) {rowMessage += "具体项目名称不能为空;";} else if (hzjtlxnameid.length() > 240) {rowMessage += "具体项目名称长度不能超过24;";}
//                        tempUserKB.setHzjtlxnameid(hzjtlxnameid);tempUserKB.setHzjtlxnameid(FieldDictUtil.get("khsjgl", "kh_customer", "hzjtlxnameid", hzjtlxnameid));} else if (c == 38) {remarks = cell.getStringCellValue();if (StringUtils.isEmpty(remarks)) {rowMessage += "remarks不能为空;";} else if (remarks.length() > 240) {rowMessage += "remarks长度不能超过24;";}
//                        tempUserKB.setRemarks(remarks);tempUserKB.setRemarks(FieldDictUtil.get("khsjgl", "kh_customer", "remarks", remarks));} else if (c == 39) {cooperation = cell.getStringCellValue();if (StringUtils.isEmpty(cooperation)) {rowMessage += "是否合作过不能为空;";} else if (cooperation.length() > 240) {rowMessage += "是否合作过长度不能超过24;";}
//                        tempUserKB.setCooperation(cooperation);tempUserKB.setCooperation(FieldDictUtil.get("khsjgl", "kh_customer", "cooperation", cooperation));} else if (c == 40) {first_time = cell.getStringCellValue();if (StringUtils.isEmpty(first_time)) {rowMessage += "初次见面不能为空;";} else if (last_time.length() > 240) {rowMessage += "初次见面长度不能超过24;";}
//                        tempUserKB.setFirstTime(new SimpleDateFormat().parse(first_time));tempUserKB.setFirstTime(new SimpleDateFormat().parse(FieldDictUtil.get("khsjgl", "kh_customer", "first_time", first_time)));} else if (c == 41) {last_time = cell.getStringCellValue();if (StringUtils.isEmpty(last_time)) {rowMessage += "最后一次见面不能为空;";} else if (last_time.length() > 240) {rowMessage += "最后一次见面长度不能超过24;";}
//                        tempUserKB.setLastTime(new SimpleDateFormat().parse(last_time));tempUserKB.setLastTime(new SimpleDateFormat().parse(FieldDictUtil.get("khsjgl", "kh_customer", "last_time", last_time)));} else if (c == 42) {intention = cell.getStringCellValue();if (StringUtils.isEmpty(intention)) {rowMessage += "合作意向不能为空;";} else if (intention.length() > 240) {rowMessage += "合作意向长度不能超过24;";}
//                        tempUserKB.setIntention(intention);tempUserKB.setIntention(FieldDictUtil.get("khsjgl", "kh_customer", "intention", intention));} else if (c == 43) {content = cell.getStringCellValue();if (StringUtils.isEmpty(content)) {rowMessage += "合作内容不能为空;";} else if (content.length() > 240) {rowMessage += "合作内容长度不能超过24;";}
//                        tempUserKB.setContent(content);tempUserKB.setContent(FieldDictUtil.get("khsjgl", "kh_customer", "content", content));} else if (c == 44) {money = cell.getStringCellValue();if (StringUtils.isEmpty(money)) {rowMessage += "合作金额不能为空;";} else if (money.length() > 240) {rowMessage += "合作金额的长度不能超过24;";}
//                        tempUserKB.setMoney(money);tempUserKB.setMoney(FieldDictUtil.get("khsjgl", "kh_customer", "money", money));} else if (c == 45) {date = cell.getStringCellValue();if (StringUtils.isEmpty(date)) {rowMessage += "合作日期不能为空;";} else if (date.length() > 240) {rowMessage += "合作日期长度不能超过24;";}
//                        tempUserKB.setDate(date);tempUserKB.setDate(FieldDictUtil.get("khsjgl", "kh_customer", "date", date));} else if (c == 46) {sources = cell.getStringCellValue();if (StringUtils.isEmpty(sources)) {rowMessage += "社会资源不能为空;";} else if (sources.length() > 500) {rowMessage += "社会资源长度不能超过24;";}
//                        tempUserKB.setResources(sources);tempUserKB.setResources(FieldDictUtil.get("khsjgl", "kh_customer", "sources", sources));} else if (c == 47) {create_by = cell.getStringCellValue();if (StringUtils.isEmpty(create_by)) {rowMessage += "客户创建人不能为空;";} else if (create_by.length() > 5) {rowMessage += "客户创建人长度不能超过24;";}
//                        tempUserKB.setCreateBy(create_by);tempUserKB.setCreateBy(FieldDictUtil.get("khsjgl", "kh_customer", "create_by", create_by));} else if (c == 48) {create_date = cell.getStringCellValue();if (StringUtils.isEmpty(create_date)) {rowMessage += "客户创建时间不能为空;";}
//                        else if (create_date.length() > 240) {//                            rowMessage += "客户创建时间长度不能超过24;";
//                        }
//                        tempUserKB.setCreateDate(new SimpleDateFormat().parse(create_date));tempUserKB.setCreateDate(new SimpleDateFormat().parse(FieldDictUtil.get("khsjgl", "kh_customer", "create_date", create_date)));}else if (c == 49) {enabled_flag = cell.getStringCellValue();if (StringUtils.isEmpty(enabled_flag)) {rowMessage += "客户创建时间不能为空;";}
//                        else if (create_date.length() > 240) {//                            rowMessage += "客户创建时间长度不能超过24;";
//                        }
//                        tempUserKB.setCreateDate(new SimpleDateFormat().parse(create_date));tempUserKB.setEnabledFlag(Integer.valueOf(FieldDictUtil.get("khsjgl", "kh_customer", "enabled_flag", enabled_flag)));}else if (c == 50) {confirm_status = cell.getStringCellValue();if (StringUtils.isEmpty(create_date)) {rowMessage += "客户创建时间不能为空;";}else if (confirm_status.length() > 240) {rowMessage += "客户创建时间长度不能超过24;";}
//                        tempUserKB.setCreateDate(new SimpleDateFormat().parse(create_date));tempUserKB.setConfirmStatus(FieldDictUtil.get("khsjgl", "kh_customer", "confirm_status", confirm_status));}} else {rowMessage += "第" + (c + 1) + "列数据有问题,请仔细检查;";}}//拼接每行的错误提示if (!StringUtils.isEmpty(rowMessage)) {errorMsg += br + "第" + (r + 1) + "行," + rowMessage;} else {userKnowledgeBaseList.add(tempUserKB);}}

使用

//新建一个文件File tempFile = new File(Filepath + System.currentTimeMillis() + ".xlsx");//初始化输入流InputStream is = null;try {//将上传的文件写入新建的文件中file.transferTo(tempFile);//根据新建的文件实例化输入流is = new FileInputStream(tempFile);//根据版本选择创建Workbook的方式Workbook wb = null;//根据文件名判断文件是2003版本还是2007版本if (ExcelImportUtils.isExcel2007(fileName)) {wb = new XSSFWorkbook(is);} else {wb = new HSSFWorkbook(is);}//根据excel里面的内容读取知识库信息return readExcelValue(wb, tempFile);

java解析Excel里面的数据相关推荐

  1. Java 解析Excel(xls、xlsx两种格式)

    Java 解析Excel(xls.xlsx两种格式) 一.环境 JDK 1.8 二.JAR 1.commons-collections4-4.1.jar 2.poi-3.9-20121203.jar ...

  2. java解析Excel文件

    下文介绍java解析Excel文件的方案 前置准备 1.第三方jar包或者Maven配置 org.apache.poi的jar包 Maven配置如下 <groupId>org.apache ...

  3. 【转帖】Java实现Excel批量导入数据

    这篇文章主要为大家详细介绍了Java实现Excel批量导入数据,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下 Excel的批量导入是很常见的功能,这里采用Jxl实现,数 ...

  4. java解析Excel文件的方法

    java解析Excel文件的方法 介绍 1.1 pom依赖 1.2 将数据流转化为可解析的Workbook类型文件 1.3 解析 1.4 Controller层接收前端传递的Excel文件(前端使用E ...

  5. springboot -- 整合 poi 解析Excel 更新数据库数据

    目录: 1.建表,实体类,dao层,service层,自行操作 2.Excel–>Poi --> Maven依赖 3.解析Excel --> Poi 工具类 --> Confi ...

  6. java解析excel的工具_Java 解析 Excel 工具 easyexcel

    软件介绍 easyexcel -- JAVA 解析 Excel 工具 Java 解析.生成 Excel 比较有名的框架有 Apache poi.jxl .但他们都存在一个严重的问题就是非常的耗内存,p ...

  7. [转]VS2010+MFC解析Excel文件中数据

    本文转自:http://www.vcfans.com/2010/08/vs2010-mfc-excel-file-in-the-data-analysis.html 前两天折腾一个小功能,需求是解析E ...

  8. JAVA获取excel第一列数据

    JAVA获取excel第一列数据 提示 1:需要将.xlsx格式转为.xls(不懂得自行百度) 2:不要一次读取太多数据,导致内存溢出 一个简单的方法========== @GetMapping(&q ...

  9. Java 解析CA证书 对数据进行签名和验签

    Java 解析CA证书 对数据进行签名和验签 话不多说直接上代码(pfx证书) pom依赖 <dependency><groupId>org.apache.commons< ...

最新文章

  1. 基于matlab的元音共振峰的估算
  2. 在CentOS上安装Python
  3. 【Android 安全】DEX 加密 ( Application 替换 | Android 应用启动原理 )
  4. 用函数的思想进行四则运算
  5. Android+Java中使用RSA加密实现接口调用时的校验功能
  6. 我的MYSQL学习心得(一)
  7. Android style 继承
  8. mysql publishedtime_MySQL数据库中的Date,DateTime,TimeStamp和Time类型
  9. 在 Visual Studio 2013 中使用 JavaScript 的 IntelliSense
  10. 基于Scrapy+MySQL爬取国家药监局100w+数据踩坑记录
  11. 阿里云IPV6解决方案
  12. 使用jQuery Easyui 制作的后台界面
  13. 《Python渗透测试编程技术:方法与实践》:信息的利用(进阶)
  14. linux卸载小企鹅输入法,Linux(FC)小企鹅输入法的安装
  15. 【Java 8 新特性】Java LocalDateTime 和 Epoch 互相转换
  16. 喜羊羊与灰太狼java_java swing实现喜羊羊与灰太狼推箱子游戏附带视频开发教程...
  17. java调用百度翻译_Java调用百度API实现翻译-Go语言中文社区
  18. jvm-8-java
  19. 软件体系结构网课第一次笔记
  20. python中numpy zeros_为什么numpy.zeros和numpy.zeros的性能不同?

热门文章

  1. 各大互联网大厂年终奖一览表,又是别人家的公司!
  2. 柯朗微积分与数学分析习题选解(1.1 节 a)
  3. 2016计算机学科夏令营上机考试C:反反复复(字符串处理)
  4. 猫狗大战——基于TensorFlow的猫狗识别(2)
  5. Element-ui源码分析之滚动条— el-scrollbar
  6. 表现层(UI)、业务逻辑层(BLL)、数据访问层(DAL)
  7. java拼音搜索排序算法_Java汉字按照拼音排序
  8. 03 TI OMAPL138E Linux移植 (Davinci) (资源获取+从串口启动UBoot+从网络启动Linux与文件系统)
  9. oracle把数据分开,Oracle初学者入门指南-系统与用户数据分离
  10. CAD图纸怎么转换PDF格式?怎样转换更加高效?