Package io.keikai.model.impl.sys.formula
Class EvalBook
- java.lang.Object
-
- io.keikai.model.impl.sys.formula.EvalBook
-
- All Implemented Interfaces:
Serializable,EvaluationWorkbook,FormulaParsingWorkbook
public final class EvalBook extends Object implements EvaluationWorkbook, FormulaParsingWorkbook, Serializable
modified from org.apache.poi.xssf.usermodel.XSSFEvaluationWorkbook- Author:
- Josh Micich, Pao
- See Also:
- Serialized Form
-
-
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 Instance Methods Concrete Methods Modifier and Type Method Description voidclearAllCachedResultValues()Propagated fromWorkbookEvaluator.clearAllCachedResultValues()to clear locally cached data.intconvertFromExternSheetIndex(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 sheetsintconvertLastIndexFromExternSheetIndex(int externSheetIndex)NamecreateName()Return the underlying workbookTablePtgcreateTablePtg(String tableName, Object[] specifiers, int sheetIndex, int rowIdx, int colIdx)Ptgget3DReferencePtg(AreaReference area, SheetIdentifier sheet)Produce the appropriate Ptg for a 3d area referencePtgget3DReferencePtg(CellReference cell, SheetIdentifier sheet)Produce the appropriate Ptg for a 3d cell referenceStringgetBookNameFromExternalLinkIndex(String externalLinkIndex)Return the associated book name of the specified ExternalLink index.EvaluationWorkbook.ExternalNamegetExternalName(int externSheetIndex, int externNameIndex)HSSF Only - fetch the external-style name detailsEvaluationWorkbook.ExternalNamegetExternalName(String nameName, String sheetName, int externalWorkbookNumber)XSSF Only - fetch the external-style name detailsEvaluationWorkbook.ExternalSheetgetExternalSheet(int externSheetIndex)HSSF Only - fetch the external-style sheet detailsEvaluationWorkbook.ExternalSheetgetExternalSheet(String firstSheetName, String lastSheetName, int externalWorkbookNumber)XSSF Only - fetch the external-style sheet detailsintgetExternalSheetIndex(String sheetName)gets the externSheet index for a sheet from this workbookintgetExternalSheetIndex(String workbookName, String sheetName)gets the externSheet index for a sheet from an external workbookMap<String,Formula>getFormulaParsingCache()Ptg[]getFormulaTokens(int sheetIndex, String formula)Ptg[]getFormulaTokens(EvaluationCell cell)EvaluationNamegetName(String name, int sheetIndex)named range name matching is case insensitiveEvaluationNamegetName(String name, String sheetName)named range name matching is case-insensitiveEvaluationNamegetName(NamePtg namePtg)EvaluationNamegetName(NamePtg namePtg, int contextSheetIndex)PtggetNameXPtg(String name, SheetIdentifier sheet)Return an external name (named range, function, user-defined function) PtgSBookgetNBook()EvaluationNamegetOrCreateName(String name, int sheetIndex)EvaluationSheetgetSheet(int sheetIndex)Get the sheet identified by the given 0-based index.intgetSheetIndex(String sheetName)Finds a sheet index by case insensitive name.intgetSheetIndex(EvaluationSheet evalSheet)StringgetSheetName(int sheetIndex)Returns the name of the sheet at the given 0-based index.SpreadsheetVersiongetSpreadsheetVersion()Returns an enum holding spreadhseet properties specific to an Excel version ( max column and row numbers, max arguments to a function, etc.)TablegetTable(String name)XSSF Only - gets a table that exists in the worksheetStringgetTableName(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.UDFFindergetUDFFinder()booleanisAllowedDeferredNamePtg()In HSSF, we need to render a formula string from stored Ptg, so a formula cannot be parsed to DeferredNamePtg.StringresolveNameXText(NameXPtg n)
-
-
-
Constructor Detail
-
EvalBook
public EvalBook(SBook book)
-
-
Method Detail
-
getNBook
public SBook getNBook()
-
getFormulaTokens
public Ptg[] getFormulaTokens(EvaluationCell cell)
- Specified by:
getFormulaTokensin interfaceEvaluationWorkbook
-
getFormulaTokens
public Ptg[] getFormulaTokens(int sheetIndex, String formula)
- Specified by:
getFormulaTokensin interfaceEvaluationWorkbook
-
getName
public EvaluationName getName(String name, int sheetIndex)
Description copied from interface:FormulaParsingWorkbooknamed range name matching is case insensitive- Specified by:
getNamein interfaceEvaluationWorkbook- Specified by:
getNamein interfaceFormulaParsingWorkbook
-
getName
public EvaluationName getName(NamePtg namePtg)
- Specified by:
getNamein interfaceEvaluationWorkbook
-
getName
public EvaluationName getName(NamePtg namePtg, int contextSheetIndex)
-
getExternalName
public EvaluationWorkbook.ExternalName getExternalName(int externSheetIndex, int externNameIndex)
Description copied from interface:EvaluationWorkbookHSSF Only - fetch the external-style name details- Specified by:
getExternalNamein interfaceEvaluationWorkbook
-
getUDFFinder
public UDFFinder getUDFFinder()
- Specified by:
getUDFFinderin interfaceEvaluationWorkbook
-
getSheet
public EvaluationSheet getSheet(int sheetIndex)
Description copied from interface:EvaluationWorkbookGet the sheet identified by the given 0-based index.- Specified by:
getSheetin interfaceEvaluationWorkbook- Parameters:
sheetIndex- The 0-based index of the sheet- Returns:
- The sheet
-
getSheetIndex
public int getSheetIndex(EvaluationSheet evalSheet)
- Specified by:
getSheetIndexin interfaceEvaluationWorkbook- Returns:
- -1 if the specified sheet is from a different book
-
getSheetIndex
public int getSheetIndex(String sheetName)
Description copied from interface:EvaluationWorkbookFinds a sheet index by case insensitive name.- Specified by:
getSheetIndexin 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:EvaluationWorkbookReturns the name of the sheet at the given 0-based index.- Specified by:
getSheetNamein interfaceEvaluationWorkbook- Parameters:
sheetIndex- The 0-based index of the sheet- Returns:
- The name of the sheet
-
getExternalSheet
public EvaluationWorkbook.ExternalSheet getExternalSheet(int externSheetIndex)
Description copied from interface:EvaluationWorkbookHSSF Only - fetch the external-style sheet detailsReturn will have no workbook set if it's actually in our own workbook
- Specified by:
getExternalSheetin interfaceEvaluationWorkbook- Returns:
- The found sheet or null if not found
-
resolveNameXText
public String resolveNameXText(NameXPtg n)
- Specified by:
resolveNameXTextin interfaceEvaluationWorkbook
-
convertFromExternSheetIndex
public int convertFromExternSheetIndex(int externSheetIndex)
Description copied from interface:EvaluationWorkbookHSSF 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:
convertFromExternSheetIndexin interfaceEvaluationWorkbook- Returns:
- the sheet index of the sheet with the given external index.
-
convertLastIndexFromExternSheetIndex
public int convertLastIndexFromExternSheetIndex(int externSheetIndex)
- Specified by:
convertLastIndexFromExternSheetIndexin interfaceEvaluationWorkbook
-
getExternalSheetIndex
public int getExternalSheetIndex(String sheetName)
Description copied from interface:FormulaParsingWorkbookgets the externSheet index for a sheet from this workbook- Specified by:
getExternalSheetIndexin interfaceFormulaParsingWorkbook
-
getExternalSheetIndex
public int getExternalSheetIndex(String workbookName, String sheetName)
Description copied from interface:FormulaParsingWorkbookgets the externSheet index for a sheet from an external workbook- Specified by:
getExternalSheetIndexin interfaceFormulaParsingWorkbook- Parameters:
workbookName- e.g. "Budget.xls"sheetName- a name of a sheet in that workbook
-
getExternalSheet
public EvaluationWorkbook.ExternalSheet getExternalSheet(String firstSheetName, String lastSheetName, int externalWorkbookNumber)
Description copied from interface:EvaluationWorkbookXSSF Only - fetch the external-style sheet detailsReturn will have no workbook set if it's actually in our own workbook
- Specified by:
getExternalSheetin interfaceEvaluationWorkbook- Returns:
- The found sheet
-
getExternalName
public EvaluationWorkbook.ExternalName getExternalName(String nameName, String sheetName, int externalWorkbookNumber)
Description copied from interface:EvaluationWorkbookXSSF Only - fetch the external-style name details- Specified by:
getExternalNamein interfaceEvaluationWorkbook
-
clearAllCachedResultValues
public void clearAllCachedResultValues()
Description copied from interface:EvaluationWorkbookPropagated fromWorkbookEvaluator.clearAllCachedResultValues()to clear locally cached data. Implementations must call the same method on all referencedEvaluationSheetinstances, as well as clearing local caches.- Specified by:
clearAllCachedResultValuesin interfaceEvaluationWorkbook- See Also:
WorkbookEvaluator.clearAllCachedResultValues()
-
createName
public Name createName()
Description copied from interface:FormulaParsingWorkbookReturn the underlying workbook- Specified by:
createNamein interfaceFormulaParsingWorkbook
-
getTable
public Table getTable(String name)
Description copied from interface:FormulaParsingWorkbookXSSF Only - gets a table that exists in the worksheet- Specified by:
getTablein interfaceFormulaParsingWorkbook
-
getNameXPtg
public Ptg getNameXPtg(String name, SheetIdentifier sheet)
Description copied from interface:FormulaParsingWorkbookReturn an external name (named range, function, user-defined function) Ptg- Specified by:
getNameXPtgin interfaceFormulaParsingWorkbook
-
get3DReferencePtg
public Ptg get3DReferencePtg(CellReference cell, SheetIdentifier sheet)
Description copied from interface:FormulaParsingWorkbookProduce the appropriate Ptg for a 3d cell reference- Specified by:
get3DReferencePtgin interfaceFormulaParsingWorkbook
-
get3DReferencePtg
public Ptg get3DReferencePtg(AreaReference area, SheetIdentifier sheet)
Description copied from interface:FormulaParsingWorkbookProduce the appropriate Ptg for a 3d area reference- Specified by:
get3DReferencePtgin interfaceFormulaParsingWorkbook
-
getSpreadsheetVersion
public SpreadsheetVersion getSpreadsheetVersion()
Description copied from interface:FormulaParsingWorkbookReturns an enum holding spreadhseet properties specific to an Excel version ( max column and row numbers, max arguments to a function, etc.)- Specified by:
getSpreadsheetVersionin interfaceEvaluationWorkbook- Specified by:
getSpreadsheetVersionin interfaceFormulaParsingWorkbook
-
getBookNameFromExternalLinkIndex
public String getBookNameFromExternalLinkIndex(String externalLinkIndex)
Description copied from interface:FormulaParsingWorkbookReturn 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:
getBookNameFromExternalLinkIndexin interfaceFormulaParsingWorkbook- Parameters:
externalLinkIndex- external link index- Returns:
- the associated book name of the specified ExternalLink index.
-
getOrCreateName
public EvaluationName getOrCreateName(String name, int sheetIndex)
-
isAllowedDeferredNamePtg
public boolean isAllowedDeferredNamePtg()
Description copied from interface:FormulaParsingWorkbookIn 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:
isAllowedDeferredNamePtgin 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.
-
getName
public EvaluationName getName(String name, String sheetName)
Description copied from interface:FormulaParsingWorkbooknamed range name matching is case-insensitive- Specified by:
getNamein interfaceFormulaParsingWorkbook
-
createTablePtg
public TablePtg createTablePtg(String tableName, Object[] specifiers, int sheetIndex, int rowIdx, int colIdx)
- Specified by:
createTablePtgin interfaceFormulaParsingWorkbook- Returns:
-
getTableName
public String getTableName(String name)
Description copied from interface:FormulaParsingWorkbookGiven 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:
getTableNamein interfaceFormulaParsingWorkbook- Returns:
-
-