The problem of Java reading excel decimal point

when you use Java to read excel, the decimal is automatically converted to an imprecise decimal point.

read the code of excel

    public static List<String[]> readExcel(File file) throws Exception {
        //
         List<String[]> dataList = new ArrayList<String[]>(); 
        //Workbook  
        Workbook workbook = getWorkBook(file); 
        if (workbook == null) 
            throw new Exception("excelworkbook build null");
        for (int sheetNum = 0; sheetNum < workbook.getNumberOfSheets(); sheetNumPP) {
            //sheet  
            Sheet sheet = workbook.getSheetAt(sheetNum);  
            if (sheet == null)   
                continue;  
            if (sheet.getNumMergedRegions() > 0)  
                setSheetMergedRegionsValue(sheet); 
            //sheet  
            int firstRowNum  = sheet.getFirstRowNum();  
            //sheet  
            int lastRowNum = sheet.getLastRowNum();   
            //  
            for (int rowNum = firstRowNum; rowNum <= lastRowNum; rowNumPP) {
                //  
                Row row = sheet.getRow(rowNum);  
                if (row == null)   
                    continue;  
                //  
                int firstCellNum = row.getFirstCellNum();  
                //  
                int lastCellNum = row.getPhysicalNumberOfCells();  
                String[] cells = new String[row.getPhysicalNumberOfCells()];  
                //  
                for (int cellNum = firstCellNum; cellNum < lastCellNum; cellNumPP) {   
                    if (cellNum < 0)
                        continue;
                    Cell cell = row.getCell(cellNum);  
                    if (cell == null)
                        continue;
                    cell.setCellType(Cell.CELL_TYPE_STRING); 
                    cells[cellNum] = cell.getStringCellValue(); 
                }  
                // continue
                if (cells.length > 0 && StringUtils.isBlank(cells[0]))
                    continue;
                dataList.add(cells);
            }
        }
        //workbook.close();
        
        return dataList;
    }

excel raw file

clipboard.png

clipboard.png

how to solve this problem?

Mar.20,2021

if the original cell is numeric, this is normal, because the floating point number is a little error, what you need to do is to keep the corresponding decimal places according to different columns.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e3bc01-42c0d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e3bc01-42c0d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?