Package org.apache.poi.hssf.usermodel
Class HSSFEvaluationWorkbook
- java.lang.Object
-
- org.apache.poi.hssf.usermodel.HSSFEvaluationWorkbook
-
- All Implemented Interfaces:
EvaluationWorkbook
,FormulaParsingWorkbook
,FormulaRenderingWorkbook
@Internal public final class HSSFEvaluationWorkbook extends Object implements FormulaRenderingWorkbook, EvaluationWorkbook, FormulaParsingWorkbook
Internal POI use only
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.poi.ss.formula.EvaluationWorkbook
EvaluationWorkbook.ExternalName, EvaluationWorkbook.ExternalSheet, EvaluationWorkbook.ExternalSheetRange
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearAllCachedResultValues()
Propagated fromWorkbookEvaluator.clearAllCachedResultValues()
to clear locally cached data.int
convertFromExternSheetIndex(int externSheetIndex)
HSSF Only - convert an external sheet index to an internal sheet index, for an external-style reference to one of this workbook's own sheetsstatic HSSFEvaluationWorkbook
create(HSSFWorkbook book)
HSSFName
createName()
Return the underlying workbookTablePtg
createTablePtg(String tableName, Object[] specifiers, int sheetIndex, int rowIdx, int colIdx)
Ptg
get3DReferencePtg(AreaReference areaRef, SheetIdentifier sheet)
Produce the appropriate Ptg for a 3d area referencePtg
get3DReferencePtg(CellReference cr, SheetIdentifier sheet)
Produce the appropriate Ptg for a 3d cell referenceString
getBookNameFromExternalLinkIndex(String externalLinkIndex)
Return the associated book name of the specified ExternalLink index.String
getExternalLinkIndexFromBookName(String bookname)
EvaluationWorkbook.ExternalName
getExternalName(int externSheetIndex, int externNameIndex)
HSSF Only - fetch the external-style name detailsEvaluationWorkbook.ExternalName
getExternalName(String nameName, String sheetName, int externalWorkbookNumber)
XSSF Only - fetch the external-style name detailsEvaluationWorkbook.ExternalSheet
getExternalSheet(int externSheetIndex)
HSSF Only - fetch the external-style sheet detailsEvaluationWorkbook.ExternalSheet
getExternalSheet(String firstSheetName, String lastSheetName, int externalWorkbookNumber)
XSSF Only - fetch the external-style sheet detailsint
getExternalSheetIndex(String sheetName)
gets the externSheet index for a sheet from this workbookint
getExternalSheetIndex(String workbookName, String sheetName)
gets the externSheet index for a sheet from an external workbookPtg[]
getFormulaTokens(int sheetIndex, String formula)
Ptg[]
getFormulaTokens(EvaluationCell evalCell)
EvaluationName
getName(String name, int sheetIndex)
Lookup a named range by its name.EvaluationName
getName(String name, String sheetName)
named range name matching is case-insensitiveEvaluationName
getName(NamePtg namePtg)
String
getNameText(NamePtg namePtg)
NameXPtg
getNameXPtg(String name, SheetIdentifier sheet)
Return an external name (named range, function, user-defined function) PtgEvaluationSheet
getSheet(int sheetIndex)
Get the sheet identified by the given 0-based index.String
getSheetFirstNameByExternSheet(int externSheetIndex)
int
getSheetIndex(String sheetName)
Finds a sheet index by case insensitive name.int
getSheetIndex(EvaluationSheet evalSheet)
String
getSheetLastNameByExternSheet(int externSheetIndex)
String
getSheetName(int sheetIndex)
Returns the name of the sheet at the given 0-based index.SpreadsheetVersion
getSpreadsheetVersion()
Returns an enum holding spreadhseet properties specific to an Excel version ( max column and row numbers, max arguments to a function, etc.)Table
getTable(String name)
XSSF Only - gets a table that exists in the worksheetString
getTableName(String name)
Given a name and return the real table name(consider uppercase/lowecase); It can be used to check whether the specified name is a table name if the returned name is null.UDFFinder
getUDFFinder()
boolean
isAllowedDeferredNamePtg()
In HSSF, we need to render a formula string from stored Ptg, so a formula cannot be parsed to DeferredNamePtg.String
resolveNameXText(NameXPtg n)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.poi.ss.formula.EvaluationWorkbook
convertLastIndexFromExternSheetIndex
-
-
-
-
Method Detail
-
create
public static HSSFEvaluationWorkbook create(HSSFWorkbook book)
-
clearAllCachedResultValues
public void clearAllCachedResultValues()
Description copied from interface:EvaluationWorkbook
Propagated fromWorkbookEvaluator.clearAllCachedResultValues()
to clear locally cached data. Implementations must call the same method on all referencedEvaluationSheet
instances, as well as clearing local caches.- Specified by:
clearAllCachedResultValues
in interfaceEvaluationWorkbook
- See Also:
WorkbookEvaluator.clearAllCachedResultValues()
-
createName
public HSSFName createName()
Description copied from interface:FormulaParsingWorkbook
Return the underlying workbook- Specified by:
createName
in interfaceFormulaParsingWorkbook
-
getExternalSheetIndex
public int getExternalSheetIndex(String sheetName)
Description copied from interface:FormulaParsingWorkbook
gets the externSheet index for a sheet from this workbook- Specified by:
getExternalSheetIndex
in interfaceFormulaParsingWorkbook
-
getExternalSheetIndex
public int getExternalSheetIndex(String workbookName, String sheetName)
Description copied from interface:FormulaParsingWorkbook
gets the externSheet index for a sheet from an external workbook- Specified by:
getExternalSheetIndex
in interfaceFormulaParsingWorkbook
- Parameters:
workbookName
- e.g. "Budget.xls"sheetName
- a name of a sheet in that workbook
-
get3DReferencePtg
public Ptg get3DReferencePtg(CellReference cr, SheetIdentifier sheet)
Description copied from interface:FormulaParsingWorkbook
Produce the appropriate Ptg for a 3d cell reference- Specified by:
get3DReferencePtg
in interfaceFormulaParsingWorkbook
-
get3DReferencePtg
public Ptg get3DReferencePtg(AreaReference areaRef, SheetIdentifier sheet)
Description copied from interface:FormulaParsingWorkbook
Produce the appropriate Ptg for a 3d area reference- Specified by:
get3DReferencePtg
in interfaceFormulaParsingWorkbook
-
getNameXPtg
public NameXPtg getNameXPtg(String name, SheetIdentifier sheet)
Return an external name (named range, function, user-defined function) Ptg- Specified by:
getNameXPtg
in interfaceFormulaParsingWorkbook
-
getName
public EvaluationName getName(String name, int sheetIndex)
Lookup a named range by its name.- Specified by:
getName
in interfaceEvaluationWorkbook
- Specified by:
getName
in interfaceFormulaParsingWorkbook
- Parameters:
name
- the name to searchsheetIndex
- the 0-based index of the sheet this formula belongs to. The sheet index is required to resolve sheet-level names.-1
means workbook-global names
-
isAllowedDeferredNamePtg
public boolean isAllowedDeferredNamePtg()
Description copied from interface:FormulaParsingWorkbook
In HSSF, we need to render a formula string from stored Ptg, so a formula cannot be parsed to DeferredNamePtg. Because DeferredNamePtg will be read as UnknownPtg for it's not written out.- Specified by:
isAllowedDeferredNamePtg
in interfaceFormulaParsingWorkbook
- Returns:
- true for using DeferredNamePtg to represent a non-existed defined name during formula parsing. If false, parser will create a defined name for a non-existed one.
-
getBookNameFromExternalLinkIndex
public String getBookNameFromExternalLinkIndex(String externalLinkIndex)
Description copied from interface:FormulaParsingWorkbook
Return the associated book name of the specified ExternalLink index. Excel stores ExternalLink index in place of the [].(e.g. [1]Sheet1:Sheet3!xxx)- Specified by:
getBookNameFromExternalLinkIndex
in interfaceFormulaParsingWorkbook
- Parameters:
externalLinkIndex
- external link index- Returns:
- the associated book name of the specified ExternalLink index.
-
createTablePtg
public TablePtg createTablePtg(String tableName, Object[] specifiers, int sheetIndex, int rowIdx, int colIdx)
- Specified by:
createTablePtg
in interfaceFormulaParsingWorkbook
- Returns:
-
getTableName
public String getTableName(String name)
Description copied from interface:FormulaParsingWorkbook
Given a name and return the real table name(consider uppercase/lowecase); It can be used to check whether the specified name is a table name if the returned name is null.- Specified by:
getTableName
in interfaceFormulaParsingWorkbook
- Returns:
-
getName
public EvaluationName getName(String name, String sheetName)
Description copied from interface:FormulaParsingWorkbook
named range name matching is case-insensitive- Specified by:
getName
in interfaceFormulaParsingWorkbook
-
getSheetIndex
public int getSheetIndex(EvaluationSheet evalSheet)
- Specified by:
getSheetIndex
in interfaceEvaluationWorkbook
- Returns:
- -1 if the specified sheet is from a different book
-
getSheetIndex
public int getSheetIndex(String sheetName)
Description copied from interface:EvaluationWorkbook
Finds a sheet index by case insensitive name.- Specified by:
getSheetIndex
in interfaceEvaluationWorkbook
- Returns:
- the index of the sheet matching the specified name. -1 if not found
-
getSheetName
public String getSheetName(int sheetIndex)
Description copied from interface:EvaluationWorkbook
Returns the name of the sheet at the given 0-based index.- Specified by:
getSheetName
in interfaceEvaluationWorkbook
- Parameters:
sheetIndex
- The 0-based index of the sheet- Returns:
- The name of the sheet
-
getSheet
public EvaluationSheet getSheet(int sheetIndex)
Description copied from interface:EvaluationWorkbook
Get the sheet identified by the given 0-based index.- Specified by:
getSheet
in interfaceEvaluationWorkbook
- Parameters:
sheetIndex
- The 0-based index of the sheet- Returns:
- The sheet
-
convertFromExternSheetIndex
public int convertFromExternSheetIndex(int externSheetIndex)
Description copied from interface:EvaluationWorkbook
HSSF Only - convert an external sheet index to an internal sheet index, for an external-style reference to one of this workbook's own sheets- Specified by:
convertFromExternSheetIndex
in interfaceEvaluationWorkbook
-
getExternalSheet
public EvaluationWorkbook.ExternalSheet getExternalSheet(int externSheetIndex)
Description copied from interface:EvaluationWorkbook
HSSF Only - fetch the external-style sheet detailsReturn will have no workbook set if it's actually in our own workbook
- Specified by:
getExternalSheet
in interfaceEvaluationWorkbook
- Specified by:
getExternalSheet
in interfaceFormulaRenderingWorkbook
- Returns:
null
if externSheetIndex refers to a sheet inside the current workbook
-
getExternalSheet
public EvaluationWorkbook.ExternalSheet getExternalSheet(String firstSheetName, String lastSheetName, int externalWorkbookNumber)
Description copied from interface:EvaluationWorkbook
XSSF Only - fetch the external-style sheet detailsReturn will have no workbook set if it's actually in our own workbook
- Specified by:
getExternalSheet
in interfaceEvaluationWorkbook
- Returns:
- The found sheet
- Throws:
IllegalStateException
- XSSF-style external references are not supported for HSSF
-
getExternalName
public EvaluationWorkbook.ExternalName getExternalName(int externSheetIndex, int externNameIndex)
Description copied from interface:EvaluationWorkbook
HSSF Only - fetch the external-style name details- Specified by:
getExternalName
in interfaceEvaluationWorkbook
-
getExternalName
public EvaluationWorkbook.ExternalName getExternalName(String nameName, String sheetName, int externalWorkbookNumber)
Description copied from interface:EvaluationWorkbook
XSSF Only - fetch the external-style name details- Specified by:
getExternalName
in interfaceEvaluationWorkbook
- Throws:
IllegalStateException
- XSSF-style external names are not supported for HSSF
-
resolveNameXText
public String resolveNameXText(NameXPtg n)
- Specified by:
resolveNameXText
in interfaceEvaluationWorkbook
- Specified by:
resolveNameXText
in interfaceFormulaRenderingWorkbook
-
getSheetFirstNameByExternSheet
public String getSheetFirstNameByExternSheet(int externSheetIndex)
- Specified by:
getSheetFirstNameByExternSheet
in interfaceFormulaRenderingWorkbook
- Returns:
- the name of the (first) sheet referred to by the given external sheet index
-
getSheetLastNameByExternSheet
public String getSheetLastNameByExternSheet(int externSheetIndex)
- Specified by:
getSheetLastNameByExternSheet
in interfaceFormulaRenderingWorkbook
- Returns:
- the name of the (last) sheet referred to by the given external sheet index
-
getNameText
public String getNameText(NamePtg namePtg)
- Specified by:
getNameText
in interfaceFormulaRenderingWorkbook
-
getFormulaTokens
public Ptg[] getFormulaTokens(int sheetIndex, String formula)
- Specified by:
getFormulaTokens
in interfaceEvaluationWorkbook
-
getExternalLinkIndexFromBookName
public String getExternalLinkIndexFromBookName(String bookname)
- Specified by:
getExternalLinkIndexFromBookName
in interfaceFormulaRenderingWorkbook
-
getName
public EvaluationName getName(NamePtg namePtg)
- Specified by:
getName
in interfaceEvaluationWorkbook
-
getFormulaTokens
public Ptg[] getFormulaTokens(EvaluationCell evalCell)
- Specified by:
getFormulaTokens
in interfaceEvaluationWorkbook
-
getUDFFinder
public UDFFinder getUDFFinder()
- Specified by:
getUDFFinder
in interfaceEvaluationWorkbook
-
getSpreadsheetVersion
public SpreadsheetVersion getSpreadsheetVersion()
Description copied from interface:FormulaParsingWorkbook
Returns an enum holding spreadhseet properties specific to an Excel version ( max column and row numbers, max arguments to a function, etc.)- Specified by:
getSpreadsheetVersion
in interfaceEvaluationWorkbook
- Specified by:
getSpreadsheetVersion
in interfaceFormulaParsingWorkbook
-
getTable
public Table getTable(String name)
Description copied from interface:FormulaParsingWorkbook
XSSF Only - gets a table that exists in the worksheet- Specified by:
getTable
in interfaceFormulaParsingWorkbook
- Throws:
IllegalStateException
- data tables are not supported in Excel 97-2003 format
-
-