How to get height and width of excel sheet named range area from HSSFWorkbook POI API
.
I got one reference from google but not able to get height and width of named index area of excel sheet.
Thanks in advance.
Yes it's named range, and want height and width of cells aquired by named range. below code having "print_area" named range and want to height and width of cells.
int namedCellIdx = workbook.getNameIndex("Print_Area"); HSSFName aNamedCell = workbook.getNameAt(namedCellIdx);
// retrieve the cell at the named range and test its contents
String a = aNamedCell.getReference();
AreaReference aref = new AreaReference(aNamedCell.getRefersToFormula());
CellReference[] crefs = aref.getAllReferencedCells();
for (int i=0; i<crefs.length; i++) {
Sheet s = workbook.getSheet(crefs[i].getSheetName());
Row r = sheet.getRow(crefs[i].getRow());
System.out.println(r.getHeight());
System.out.println(sheet.getColumnWidth(crefs[i].getCol()));;
//here want height and width of "Print_area" cells
Cell c = r.getCell(crefs[i].getCol());
System.out.println(c.getStringCellValue());
// extract the cell contents based on cell type etc.
}