Reputation: 4248
I think my title is clear what I want to know. I already searched google and there's no answer to my problem.
I want to know how can I get the size or length of an specific column in POI Apache Java?
Upvotes: 0
Views: 12202
Reputation: 4248
I already found out how to get the size of column in my on way. Post another answers if you have another one for future references.
int columnSize = 0;
for (int x = 0; x < row.getLastCellNum(); x++) {
for (int y = 0; y < row.length; y++) {
columnSize = y;
}
break;
}
Upvotes: 0
Reputation: 61
Workbook workbook = new XSSFWorkbook(ExcelFile);
Sheet firstSheet = workbook.getSheetAt(0);
Iterator<Row> iterator = firstSheet.iterator();
Row nextRow = iterator.next();
rowCount = firstSheet.getLastRowNum();
columnCount = nextRow.getLastCellNum();
Upvotes: 0
Reputation: 1313
I think there is no direct method for it.you have to iterate over all rows to know the size of column.
sample :
for (Cell cell : row) {
++COLUMNCOUNT;
}
Upvotes: 0
Reputation: 373
I thought you cannot getheight for column.But you can getheight for Specific row . other way is use CellStyle to get Height(It can be done using top border+ bottom border+ font height) for specific cell.
Upvotes: 1