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;
        }
    

      

  • 相关阅读:
    有向无环图单源最短路径问题
    linux下程序编译出错解决方法
    Ceres入门笔记
    Java 中的数据结构类 Vector 和 ArrayList
    102. Binary Tree Level Order Traversal
    104. Maximum Depth of Binary Tree
    101. Symmetric Tree
    100. Same Tree
    490. The Maze
    骑士游历问题
  • 原文地址:https://www.cnblogs.com/tnsay/p/11189967.html
Copyright © 2011-2022 走看看