Java Code Examples for org.apache.poi.hssf.usermodel.HSSFWorkbook#getNameIndex()

The following examples show how to use org.apache.poi.hssf.usermodel.HSSFWorkbook#getNameIndex() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HSSFRangeHelper.java    From yarg with Apache License 2.0 5 votes vote down vote up
public static AreaReference getAreaForRange(HSSFWorkbook workbook, String rangeName) {
    int rangeNameIdx = workbook.getNameIndex(rangeName);
    if (rangeNameIdx == -1) return null;

    HSSFName aNamedRange = workbook.getNameAt(rangeNameIdx);
    return new AreaReference(aNamedRange.getRefersToFormula(), SpreadsheetVersion.EXCEL97);
}
 
Example 2
Source File: HSSFRangeHelper.java    From yarg with Apache License 2.0 5 votes vote down vote up
public static HSSFSheet getTemplateSheetForRangeName(HSSFWorkbook workbook, String rangeName) {
    int rangeNameIdx = workbook.getNameIndex(rangeName);
    if (rangeNameIdx == -1) return null;

    HSSFName aNamedRange = workbook.getNameAt(rangeNameIdx);
    String sheetName = aNamedRange.getSheetName();
    return workbook.getSheet(sheetName);
}