小编use*_*327的帖子

POI从excel读取数字数据时附加.0

我正在使用POI HSSF来读取excel数据,我正在使用JUnit来检查数据库proc RefCursor的数据.

Junit测试失败,因为来自例如100的Refcursor的数值数据与excel表100中的数据进行比较,但它失败,因为POI将其读取为100.0.

        InputStream fileInputStream = Testdb.class.getClassLoader().getResourceAsStream(fileName);
        //retrieve number of columns and rows
        int numRows=0, numCols=0, i, j, minColIndex=0, maxColIndex=0;
        POIFSFileSystem fsFileSystem = new POIFSFileSystem(fileInputStream);
        HSSFWorkbook workBook = new HSSFWorkbook(fsFileSystem);
        HSSFSheet hssfSheet = workBook.getSheetAt(0);
        Iterator rowIterator = hssfSheet.rowIterator();
        while (rowIterator.hasNext())
        {
            numRows++;
            HSSFRow hssfRow = (HSSFRow) rowIterator.next();
            Iterator iterator = hssfRow.cellIterator();
            List cellTempList = new ArrayList();
            if (numRows == 1)
            {
                minColIndex = hssfRow.getFirstCellNum();
                maxColIndex = hssfRow.getLastCellNum();
                numCols = maxColIndex;
            }
            for(int colIndex = minColIndex; colIndex < maxColIndex; colIndex++) …
Run Code Online (Sandbox Code Playgroud)

java oracle junit dbunit apache-poi

6
推荐指数
1
解决办法
4179
查看次数

标签 统计

apache-poi ×1

dbunit ×1

java ×1

junit ×1

oracle ×1