Class FormulaParserManager
- Namespace
- OfficeOpenXml.FormulaParsing
- Assembly
- EPPlus.dll
Provides access to various functionality regarding excel formula evaluation.
public class FormulaParserManager
- Inheritance
-
FormulaParserManager
- Inherited Members
Methods
AddOrReplaceFunction(string, ExcelFunction)
If the supplied functionName
does not exist, the supplied
functionImpl
implementation will be added to the formula parser.
If it exists, the existing function will be replaced by the supplied functionImpl
public void AddOrReplaceFunction(string functionName, ExcelFunction functionImpl)
Parameters
functionName
stringfunctionImpl
ExcelFunction
AttachLogger(IFormulaParserLogger)
Attaches a logger to the FormulaParser.
public void AttachLogger(IFormulaParserLogger logger)
Parameters
logger
IFormulaParserLoggerAn instance of IFormulaParserLogger
AttachLogger(FileInfo)
Attaches a logger to the formula parser that produces output to the supplied logfile.
public void AttachLogger(FileInfo logfile)
Parameters
logfile
FileInfo
CopyFunctionsFrom(ExcelWorkbook)
Copies existing ExcelFunction´s from one workbook to another.
public void CopyFunctionsFrom(ExcelWorkbook otherWorkbook)
Parameters
otherWorkbook
ExcelWorkbookThe workbook containing the forumulas to be copied.
DetachLogger()
Detaches any attached logger from the formula parser.
public void DetachLogger()
GetCalculationChain(ExcelRangeBase)
Get calculation chain
public IEnumerable<IFormulaCellInfo> GetCalculationChain(ExcelRangeBase range)
Parameters
range
ExcelRangeBase
Returns
GetCalculationChain(ExcelRangeBase, ExcelCalculationOption)
Get Calculation chain
public IEnumerable<IFormulaCellInfo> GetCalculationChain(ExcelRangeBase range, ExcelCalculationOption options)
Parameters
range
ExcelRangeBaseoptions
ExcelCalculationOption
Returns
GetImplementedFunctionNames()
Returns an enumeration of the names of all functions implemented, both the built in functions and functions added using the LoadFunctionModule method of this class.
public IEnumerable<string> GetImplementedFunctionNames()
Returns
- IEnumerable<string>
Function names in lower case
GetImplementedFunctions()
Returns an enumeration of all implemented functions, including the implementing ExcelFunction instance.
public IEnumerable<KeyValuePair<string, ExcelFunction>> GetImplementedFunctions()
Returns
- IEnumerable<KeyValuePair<string, ExcelFunction>>
An enumeration of KeyValuePair<TKey, TValue>, where the key is the function name
LoadFunctionModule(IFunctionModule)
Loads a module containing custom functions to the formula parser. By using this method you can add your own implementations of Excel functions, by implementing a IFunctionModule.
public void LoadFunctionModule(IFunctionModule module)
Parameters
module
IFunctionModuleA IFunctionModule containing ExcelFunctions.
Parse(string)
Parses the supplied formula
and returns the result.
public object Parse(string formula)
Parameters
formula
stringThe formula to parse
Returns
- object
The result of the parsed formula
Parse(string, string, bool)
Parses the supplied formula
and returns the result.
public object Parse(string formula, string address, bool writeToCell = true)
Parameters
formula
stringThe formula to parse
address
stringThe full address in the workbook where the
formula
should be parsed. Example: you might want to parse the formula of a conditional format, then this should be the address of the cell where the conditional format resides.writeToCell
boolIf writing result to adress or not, true by default
Returns
- object
The result of the parsed formula