把我的双打格子变成了双打

我正在从每个指定的列中的每一行的Excel文件,使用row.getCell(); 我想这个数据在一个ArrayList中。 我如何去转换的细胞srs的内容和ArrayList。

for(Row row : sheet){ if(row.getRowNum() == 0) continue; Cell Rk = row.getCell(2); Cell seed = row.getCell(1); Cell srs = row.getCell(7); System.out.println(srs); This is what it prints 0.974 0.588 0.213 ect. 

基于这个问题,我认为你正在寻找这样的东西:

 List<Double> list = new ArrayList<>(); for(Row row : sheet){ if(row.getRowNum() == 0) continue; Cell srs = row.getCell(7); list.add(src.getNumericCellValue()); } 

getNumericCellValue()返回单元格值为原生typesdouble 。 Java自动装箱将负责将其转换为Object-type Double

有关更多详细信息,请参阅本指南 。