zoukankan      html  css  js  c++  java
  • 数值或者*被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;
        }
    

      

  • 相关阅读:
    Spring boot 启动图片
    Spring Cloud 从入门到入门
    理解错误的 Arrays.asList()
    git github 对代码的管理
    【POJ 2154】Color
    CodeForces
    CodeForces
    CodeForces
    CodeForces
    [数据结构]Hash Table(哈希表)
  • 原文地址:https://www.cnblogs.com/tnsay/p/11189967.html
Copyright © 2011-2022 走看看