Package io.keikai.model.impl.sys.formula
Class ParsingBook
- java.lang.Object
-
- io.keikai.model.impl.sys.formula.ParsingBook
-
- All Implemented Interfaces:
Serializable
,FormulaParsingWorkbook
,FormulaRenderingWorkbook
public class ParsingBook extends Object implements FormulaParsingWorkbook, FormulaRenderingWorkbook, Serializable
A pseudo formula parsing workbook for parsing only.- Since:
- 3.5.0
- Author:
- Pao
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ParsingBook(SBook book)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Name
createName()
Return the underlying workbookTablePtg
createTablePtg(String tableName, Object[] specifiers, int sheetIndex, int rowIdx, int colIdx)
int
findExternalSheetIndex(String sheetName)
int
findExternalSheetIndex(String workbookName, String sheetName)
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 referenceEvaluationWorkbook.ExternalSheetRange
getAnyExternalSheet(int externSheetIndex)
String
getBookNameFromExternalLinkIndex(String externalLinkIndex)
Return the associated book name of the specified ExternalLink index.String
getExternalLinkIndexFromBookName(String bookname)
EvaluationWorkbook.ExternalSheet
getExternalSheet(int externSheetIndex)
int
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 workbookMap<String,Formula>
getFormulaParsingCache()
EvaluationName
getName(String name, int externSheetIndex)
named range name matching is case insensitiveEvaluationName
getName(String name, String sheetName)
named range name matching is case-insensitiveObject[]
getNameInfo(NamePtg namePtg)
String
getNameText(NamePtg namePtg)
Ptg
getNameXPtg(String name, SheetIdentifier sheet)
Return an external name (named range, function, user-defined function) PtgEvaluationName
getOrCreateName(String name, int externSheetIndex)
String
getSheetFirstNameByExternSheet(int externSheetIndex)
String
getSheetLastNameByExternSheet(int externSheetIndex)
String
getSheetNameByExternSheet(int externSheetIndex)
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.boolean
isAllowedDeferredNamePtg()
In HSSF, we need to render a formula string from stored Ptg, so a formula cannot be parsed to DeferredNamePtg.void
renameName(int sheetIndex, String oldName, String newName)
void
renameSheet(String bookName, String oldName, String newName)
rename a sheet in this parsing book directly.void
reorderSheet(String bookName, int oldIndex, int newIndex)
reorder a sheet in this parsing book directly.Object[]
resolveNameXInfo(NameXPtg nameXPtg)
String
resolveNameXText(NameXPtg nameXPtg)
-
-
-
Constructor Detail
-
ParsingBook
public ParsingBook(SBook book)
-
-
Method Detail
-
getName
public EvaluationName getName(String name, int externSheetIndex)
Description copied from interface:FormulaParsingWorkbook
named range name matching is case insensitive- Specified by:
getName
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
-
findExternalSheetIndex
public int findExternalSheetIndex(String sheetName)
- Parameters:
sheetName
- sheet name or 3D sheet name (e.g "Sheet1:Sheet3")- Returns:
- the external sheet index or -1 if not found
-
findExternalSheetIndex
public int findExternalSheetIndex(String workbookName, String sheetName)
- Parameters:
workbookName
- book name or nullsheetName
- sheet name or 3D sheet name (e.g "Sheet1:Sheet3")- Returns:
- the external sheet index or -1 if not found
-
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 interfaceFormulaParsingWorkbook
-
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.
-
getOrCreateName
public EvaluationName getOrCreateName(String name, int externSheetIndex)
-
getNameText
public String getNameText(NamePtg namePtg)
- Specified by:
getNameText
in interfaceFormulaRenderingWorkbook
-
resolveNameXText
public String resolveNameXText(NameXPtg nameXPtg)
- Specified by:
resolveNameXText
in interfaceFormulaRenderingWorkbook
-
getAnyExternalSheet
public EvaluationWorkbook.ExternalSheetRange getAnyExternalSheet(int externSheetIndex)
- Returns:
- internal or external sheet.
-
getExternalSheet
public EvaluationWorkbook.ExternalSheet getExternalSheet(int externSheetIndex)
- Specified by:
getExternalSheet
in interfaceFormulaRenderingWorkbook
- Returns:
null
if externSheetIndex refers to a sheet inside the current workbook
-
getSheetNameByExternSheet
public String getSheetNameByExternSheet(int externSheetIndex)
-
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
-
getExternalLinkIndexFromBookName
public String getExternalLinkIndexFromBookName(String bookname)
- Specified by:
getExternalLinkIndexFromBookName
in interfaceFormulaRenderingWorkbook
-
renameSheet
public void renameSheet(String bookName, String oldName, String newName)
rename a sheet in this parsing book directly. if it can't find a sheet with old name, it won't create a sheet for the new name.
-
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.
-
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
-
createName
public Name createName()
Description copied from interface:FormulaParsingWorkbook
Return the underlying workbook- Specified by:
createName
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
-
getNameXPtg
public Ptg getNameXPtg(String name, SheetIdentifier sheet)
Description copied from interface:FormulaParsingWorkbook
Return an external name (named range, function, user-defined function) Ptg- Specified by:
getNameXPtg
in interfaceFormulaParsingWorkbook
-
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
-
reorderSheet
public void reorderSheet(String bookName, int oldIndex, int newIndex)
reorder a sheet in this parsing book directly.
-
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:
-
-