title: How to get height and width of excel sheet"named index" area from HSSFWorkbook POI API
body: <p>How to get height and width of excel sheet <strong><a href="http://poi.apache.org/spreadsheet/quick-guide.html#NamedRanges" rel="nofollow">named range</a></strong> area from <code>HSSFWorkbook POI API</code>.</p>
  
  <p>I got one <a href="http://www.dummies.com/how-to/content/how-to-name-a-cell-or-range-in-excel-2010.html" rel="nofollow">reference</a> from google but not able to get height and width of named index area of excel sheet.</p>
  
  <p>Thanks in advance.</p>
  
  <p>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.                                     </p>
  
  <p>int namedCellIdx = workbook.getNameIndex("Print_Area");
          HSSFName aNamedCell = workbook.getNameAt(namedCellIdx);</p>
  
  <pre><code>    // 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&lt;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.
      }
  </code></pre>