2011-12-21 45 views
1

只需确保一件事。提取Apache POI中的电子表格列中的数据API

对于电子表格中的列,Apache POI API是否具有任何内置集合/对象,如行和单元格?

或者我必须自己创建一个并添加列中的所有单元格以进行排序等吗?还有其他更好的方法吗?

+1

也许你应该检查Apache POI:http://poi.apache.org/apidocs/index.html。有一个Column类:org.apache.poi.ss.formula.functions.Column 和ColumnHelper类。 – eboix 2011-12-21 19:23:32

回答

2

的Excel格式是基于行基于未柱 - 的文件写入与在顺序的行的每个小区,随后的行信息数位,则下一行的,以便等

细胞

所以,如果你想在列的基础上做一些事情,你需要自己收集细胞。它可能是这样的:

int columnWanted = 3; 
List<Cell> cells = new ArrayList<Cell>(); 

for (Row row : sheet) { 
    Cell c = row.getCell(columnWanted); 
    if (c == null || c.getCellType == Cell.CELL_TYPE_BLANK) { 
     // Nothing in the cell in this row, skip it 
    } else { 
     cells.add(c); 
    } 
} 

// Now use the cells array 
相关问题