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 NamecreateName()Return the underlying workbookTablePtgcreateTablePtg(String tableName, Object[] specifiers, int sheetIndex, int rowIdx, int colIdx)intfindExternalSheetIndex(String sheetName)intfindExternalSheetIndex(String workbookName, String sheetName)Ptgget3DReferencePtg(AreaReference areaRef, SheetIdentifier sheet)Produce the appropriate Ptg for a 3d area referencePtgget3DReferencePtg(CellReference cr, SheetIdentifier sheet)Produce the appropriate Ptg for a 3d cell referenceEvaluationWorkbook.ExternalSheetRangegetAnyExternalSheet(int externSheetIndex)StringgetBookNameFromExternalLinkIndex(String externalLinkIndex)Return the associated book name of the specified ExternalLink index.StringgetExternalLinkIndexFromBookName(String bookname)EvaluationWorkbook.ExternalSheetgetExternalSheet(int externSheetIndex)intgetExternalSheetIndex(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()EvaluationNamegetName(String name, int externSheetIndex)named range name matching is case insensitiveEvaluationNamegetName(String name, String sheetName)named range name matching is case-insensitiveObject[]getNameInfo(NamePtg namePtg)StringgetNameText(NamePtg namePtg)PtggetNameXPtg(String name, SheetIdentifier sheet)Return an external name (named range, function, user-defined function) PtgEvaluationNamegetOrCreateName(String name, int externSheetIndex)StringgetSheetFirstNameByExternSheet(int externSheetIndex)StringgetSheetLastNameByExternSheet(int externSheetIndex)StringgetSheetNameByExternSheet(int externSheetIndex)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.booleanisAllowedDeferredNamePtg()In HSSF, we need to render a formula string from stored Ptg, so a formula cannot be parsed to DeferredNamePtg.voidrenameName(int sheetIndex, String oldName, String newName)voidrenameSheet(String bookName, String oldName, String newName)rename a sheet in this parsing book directly.voidreorderSheet(String bookName, int oldIndex, int newIndex)reorder a sheet in this parsing book directly.Object[]resolveNameXInfo(NameXPtg nameXPtg)StringresolveNameXText(NameXPtg nameXPtg)
-
-
-
Constructor Detail
-
ParsingBook
public ParsingBook(SBook book)
-
-
Method Detail
-
getName
public EvaluationName getName(String name, int externSheetIndex)
Description copied from interface:FormulaParsingWorkbooknamed range name matching is case insensitive- Specified by:
getNamein interfaceFormulaParsingWorkbook
-
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
-
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: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 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 externSheetIndex)
-
getNameText
public String getNameText(NamePtg namePtg)
- Specified by:
getNameTextin interfaceFormulaRenderingWorkbook
-
resolveNameXText
public String resolveNameXText(NameXPtg nameXPtg)
- Specified by:
resolveNameXTextin interfaceFormulaRenderingWorkbook
-
getAnyExternalSheet
public EvaluationWorkbook.ExternalSheetRange getAnyExternalSheet(int externSheetIndex)
- Returns:
- internal or external sheet.
-
getExternalSheet
public EvaluationWorkbook.ExternalSheet getExternalSheet(int externSheetIndex)
- Specified by:
getExternalSheetin interfaceFormulaRenderingWorkbook- Returns:
nullif externSheetIndex refers to a sheet inside the current workbook
-
getSheetNameByExternSheet
public String getSheetNameByExternSheet(int externSheetIndex)
-
getSheetFirstNameByExternSheet
public String getSheetFirstNameByExternSheet(int externSheetIndex)
- Specified by:
getSheetFirstNameByExternSheetin interfaceFormulaRenderingWorkbook- Returns:
- the name of the (first) sheet referred to by the given external sheet index
-
getSheetLastNameByExternSheet
public String getSheetLastNameByExternSheet(int externSheetIndex)
- Specified by:
getSheetLastNameByExternSheetin interfaceFormulaRenderingWorkbook- Returns:
- the name of the (last) sheet referred to by the given external sheet index
-
getExternalLinkIndexFromBookName
public String getExternalLinkIndexFromBookName(String bookname)
- Specified by:
getExternalLinkIndexFromBookNamein 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: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
-
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 cr, SheetIdentifier sheet)
Description copied from interface:FormulaParsingWorkbookProduce the appropriate Ptg for a 3d cell reference- Specified by:
get3DReferencePtgin interfaceFormulaParsingWorkbook
-
get3DReferencePtg
public Ptg get3DReferencePtg(AreaReference areaRef, SheetIdentifier sheet)
Description copied from interface:FormulaParsingWorkbookProduce the appropriate Ptg for a 3d area reference- Specified by:
get3DReferencePtgin 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:
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:
-
-