數值或者電話號碼被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;
    }

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM