I'm having a problem in excel while using Apache poi. I can read across rows, but sometimes I'm in a situation where I would like to read a particular column only.
So is it possible to read any particular column like only the 'A' column only or the column 'C' only.
I'm using java language for this.
解决方案
heikkim is right, here is some sample code adapted from some code I have:
for (int rowIndex = 0; rowIndex <= sheet.getLastRowNum(); rowIndex++) {
row = sheet.getRow(rowIndex);
if (row != null) {
String key = null;
for (int colIndex = 0; colIndex < cols; colIndex++) {
if (colIndex == theColIndexYouWant) {
cell = row.getCell(colIndex);
if (cell != null) {
key = cell.getStringCellValue();
}
}
// Do something with the key here...
}
}
For the cols use something like row.getPhysicalNumberOfCells()