更新时间:2022-04-10 23:10:00
Excel文件的基础,而不是基于列列,因此要获得一列是看反过来每一行的所有值的唯一途径。有没有更快的方式来获得在列,因为在列单元格中没有存储在一起。
Excel files are row based rather than column based, so the only way to get all the values in a column is to look at each row in turn. There's no quicker way to get at the columns, because cells in a column aren't stored together.
您code可能想是这样的:
Your code probably wants to be something like:
List<Double> values = new ArrayList<Double>();
for(Row r : sheet) {
Cell c = r.getCell(columnNumber);
if(c != null) {
if(c.getCellType() == Cell.CELL_TYPE_NUMERIC) {
valuesadd(c.getNumericCellValue());
} else if(c.getCellType() == Cell.CELL_TYPE_FORMULA && c.getCachedFormulaResultType() == Cell.CELL_TYPE_NUMERIC) {
valuesadd(c.getNumericCellValue());
}
}
}
这将然后给你的所有数字的单元格值在该列中。
That'll then give you all the numeric cell values in that column.