数值或者电话号码被EXCEL转成了科学计数法,用XSSFCell 如何读取
public static Map<String, Integer> readXls() throws IOException { //用来获取每一个小号重复多次,被多少账号用了。来平均 58 agent 查询出来的数据。 Map<String, Integer> map = new HashMap<String, Integer>(); InputStream is = new FileInputStream("C:\\Users\\25\\Desktop\\dankeAnalyze\\新建文件夹\\58总数据20190613.xlsx"); XSSFWorkbook hssfWorkbook = new XSSFWorkbook(is); // 循环工作表Sheet for (int numSheet = 0; numSheet < hssfWorkbook.getNumberOfSheets(); numSheet++) { XSSFSheet hssfSheet = hssfWorkbook.getSheetAt(numSheet); if (hssfSheet == null) { continue; } // 循环行Row NumberFormat nf = NumberFormat.getInstance(); for (int rowNum = 1; rowNum <= hssfSheet.getLastRowNum(); rowNum++) { XSSFRow hssfRow = hssfSheet.getRow(rowNum); if (hssfRow != null) { String phone_58 = (nf.format(hssfRow.getCell(11).getNumericCellValue())).replace(",", ""); XSSFCell dkstatus = hssfRow.getCell(17); if(!getValue(dkstatus).equals("服务中")||phone_58==null||phone_58.length()!=11/*||!city.equals("北京")*/){ continue; } //通过 登录名获取展示手机号 if(map.containsKey(phone_58)){ map.put(phone_58, map.get(phone_58)+1); }else{ map.put(phone_58, 1); } } } } for(Map.Entry<String, Integer> entry : map.entrySet()){ System.out.println(entry.getKey()+":"+entry.getValue()); } return map; }
转载注明出处
如果本文对你有帮助,请帮忙啦~~
打开支付宝首页搜“522901509”领红包,领到大红包的小伙伴赶紧使用哦!