本文介绍了在Apache的POI API提取以s preadsheet列中的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只是想确认一件事情。

在Apache POI API是否有任何内置的集合/对象,如行和单元,对于A S preadsheet列?

Does the Apache POI API have any built-in collection/object, like row and cell, for a column in a spreadsheet?

还是我必须建立一个自己添加的所有单元格列那里做排序等?是否有任何其他更好的办法呢?

Or do I have to build one myself and add all the cells in the column there to do the sorting etc? Is there any other better way to do it?

推荐答案

excel的格式是基于行基于不列 - 该文件是在为了一个行中的每个单元格写,其次是行信息数位,然后下一行的顺序等的细胞

The excel format is row based not column based - the file is written with each cell in a row in order, followed by a few bits of row info, then the cells of the next row in order etc.

所以,如果你想要做的事列的基础上,你需要收集细胞了自己。这将会有可能是这样的:

So, if you want to do something on a column basis, you'll need to collect the cells up yourself. It'd likely be something like:

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

这篇关于在Apache的POI API提取以s preadsheet列中的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 21:27