Top Description Constructors Methods
org.apache.poi.hssf.model

public final Class HSSFFormulaParser

extends Object
Class Inheritance
Annotations
@Internal
Imports
org.apache.poi.hssf.usermodel.HSSFEvaluationWorkbook, .HSSFWorkbook, org.apache.poi.ss.formula.FormulaParseException, .FormulaParser, .FormulaParsingWorkbook, .FormulaRenderer, .FormulaType, org.apache.poi.ss.formula.ptg.Ptg, org.apache.poi.util.Internal

HSSF wrapper for the FormulaParser and FormulaRenderer

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private static FormulaParsingWorkbook
public static Ptg[]

Returns:

the parsed formula tokens
parse
(String
The formula to parse, excluding the leading equals sign
formula
,
HSSFWorkbook
The parent workbook
workbook
)

Convenience method for parsing cell formulas.

public static Ptg[]

Returns:

The parsed formula tokens
parse
(String
The formula to parse, excluding the leading equals sign
formula
,
HSSFWorkbook
The parent workbook
workbook
,
FormulaType
The type of formula
formulaType
)

public static Ptg[]

Returns:

the parsed formula tokens
parse
(String
The formula to parse
formula
,
HSSFWorkbook
The parent workbook
workbook
,
FormulaType
The type of formula
formulaType
,
int
The 0-based index of the sheet this formula belongs to. The sheet index is required to resolve sheet-level names. -1 means that the scope of the name will be ignored and the parser will match named ranges only by name
sheetIndex
)

public static String

Returns:

a human readable String
toFormulaString
(HSSFWorkbook
used for defined names and 3D references
book
,
Ptg[]
must not be null
ptgs
)

Static method to convert an array of Ptgs in RPN order to a human readable string format in infix mode.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

HSSFFormulaParserback to summary
private HSSFFormulaParser()

Method Detail

createParsingWorkbookback to summary
private static FormulaParsingWorkbook createParsingWorkbook(HSSFWorkbook book)
parseback to summary
public static Ptg[] parse(String formula, HSSFWorkbook workbook) throws FormulaParseException

Convenience method for parsing cell formulas. see parse(String, HSSFWorkbook, FormulaType, int)

Parameters
formula:String

The formula to parse, excluding the leading equals sign

workbook:HSSFWorkbook

The parent workbook

Returns:Ptg[]

the parsed formula tokens

Exceptions
FormulaParseException:
if the formula has incorrect syntax or is otherwise invalid
parseback to summary
public static Ptg[] parse(String formula, HSSFWorkbook workbook, FormulaType formulaType) throws FormulaParseException
Parameters
formula:String

The formula to parse, excluding the leading equals sign

workbook:HSSFWorkbook

The parent workbook

formulaType:FormulaType

The type of formula

Returns:Ptg[]

The parsed formula tokens

Exceptions
FormulaParseException:
if the formula has incorrect syntax or is otherwise invalid
parseback to summary
public static Ptg[] parse(String formula, HSSFWorkbook workbook, FormulaType formulaType, int sheetIndex) throws FormulaParseException
Parameters
formula:String

The formula to parse

workbook:HSSFWorkbook

The parent workbook

formulaType:FormulaType

The type of formula

sheetIndex:int

The 0-based index of the sheet this formula belongs to. The sheet index is required to resolve sheet-level names. -1 means that the scope of the name will be ignored and the parser will match named ranges only by name

Returns:Ptg[]

the parsed formula tokens

Exceptions
FormulaParseException:
if the formula has incorrect syntax or is otherwise invalid
toFormulaStringback to summary
public static String toFormulaString(HSSFWorkbook book, Ptg[] ptgs)

Static method to convert an array of Ptgs in RPN order to a human readable string format in infix mode.

Parameters
book:HSSFWorkbook

used for defined names and 3D references

ptgs:Ptg[]

must not be null

Returns:String

a human readable String