FileDocCategorySizeDatePackage
HSSFName.javaAPI DocApache Poi 3.0.14201Mon Jan 01 12:39:36 GMT 2007org.apache.poi.hssf.usermodel

HSSFName

public class HSSFName extends Object
Title: High Level Represantion of Named Range

REFERENCE:

author
Libin Roman (Vista Portal LDT. Developer)

Fields Summary
private org.apache.poi.hssf.model.Workbook
book
private NameRecord
name
Constructors Summary
protected HSSFName(org.apache.poi.hssf.model.Workbook book, NameRecord name)
Creates new HSSFName - called by HSSFWorkbook to create a sheet from scratch.

see
org.apache.poi.hssf.usermodel.HSSFWorkbook#createName()
param
name the Name Record
param
book lowlevel Workbook object associated with the sheet.

        this.book = book;
        this.name = name;
    
Methods Summary
public java.lang.StringgetNameName()
gets the name of the named range

return
named range name

        String result = name.getNameText();
        
        return result;
    
public java.lang.StringgetReference()
gets the reference of the named range

return
reference of the named range

        String result;
        result = name.getAreaReference(book);

        return result;
    
public java.lang.StringgetSheetName()
Get the sheets name which this named range is referenced to

return
sheet name, which this named range refered to

        String result ;
        short indexToExternSheet = name.getExternSheetNumber();
        
        result = book.findSheetNameFromExternSheet(indexToExternSheet);
        
        return result;
    
public voidsetNameName(java.lang.String nameName)
sets the name of the named range

param
nameName named range name to set

        name.setNameText(nameName);
        name.setNameTextLength((byte)nameName.length());
        
        //Check to ensure no other names have the same case-insensitive name
        for ( int i = book.getNumNames()-1; i >=0; i-- )
        {
        	NameRecord rec = book.getNameRecord(i);
        	if (rec != name) {
        		if (rec.getNameText().equalsIgnoreCase(getNameName()))
        			throw new IllegalArgumentException("The workbook already contains this name (case-insensitive)");
        	}
        }
    
public voidsetReference(java.lang.String ref)
sets the reference of this named range

param
ref the reference to set


        RangeAddress ra = new RangeAddress(ref);

        String sheetName = ra.getSheetName();

        if (ra.hasSheetName()) {
            setSheetName(sheetName);
        }

		//allow the poi utilities to parse it out
        name.setAreaReference(ref);

    
private voidsetSheetName(java.lang.String sheetName)
sets the sheet name which this named range referenced to

param
sheetName the sheet name of the reference

        int sheetNumber = book.getSheetIndex(sheetName);

        short externSheetNumber = book.checkExternSheet(sheetNumber);
        name.setExternSheetNumber(externSheetNumber);
//        name.setIndexToSheet(externSheetNumber);