HotXLS Docs

Calculate method

Calculates the result of specified expression
The built-in evaluator supports arithmetic, cell and range references, defined-name ranges, and these function groups: text functions (TRIM, PROPER, CLEAN, CHAR, CODE, T, EXACT, REPT, FIND, SEARCH, SUBSTITUTE, REPLACE); date functions (EDATE, EOMONTH, DATEDIF, YEARFRAC, DAYS, WEEKNUM, ISOWEEKNUM); workday functions (WORKDAY, NETWORKDAYS); engineering/base-conversion functions (DEC2BIN, DEC2HEX, DEC2OCT, BIN2DEC, BIN2HEX, BIN2OCT, OCT2DEC, OCT2BIN, OCT2HEX, HEX2DEC, HEX2BIN, HEX2OCT, BASE, DECIMAL, ARABIC); bitwise functions (BITAND, BITOR, BITXOR, BITLSHIFT, BITRSHIFT); statistical functions (VAR, VARP, STDEV, STDEVP, MODE, VARA, VARPA, STDEVA, STDEVPA); aggregate functions (PRODUCT, SUMSQ); math functions (GCD, LCM, MROUND, QUOTIENT, MULTINOMIAL) Custom or unsupported worksheet functions can still be resolved through OnUserFunction / OnUserFunctionEx

Syntax

function Calculate(Expression: WideString):Variant;
Expression WideString. A string that specifies an expression which should be calculated

Example

This example calculates the simple expression

Val := Workbook.Calculate('100/2*3');
This example calculates a text expression

Val := Workbook.Calculate('SUBSTITUTE("a-b-c";"-";"+")');
This example determines the smallest value in a range A1:F10 on active Worksheet

Val := Workbook.Calculate('MIN(A1:F10)');
This example is the same to previous

Val := Workbook.ActiveSheet.Calculate('MIN(A1:F10)');

See also

OnUserFunction callback
TXLSWorksheet.Calculate method