Calculates the result of specified expression
The built-in evaluator supports arithmetic, cell e range references, defined-name ranges, e these funzione 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 o unsupported worksheet functions can still be resolved through
OnUserFunction / OnUserFunctionEx
Sintassi
funzione Calculate(Expression: WideString):Variant;
| Expression |
WideString. A string that specifies an expression which should be calculated |
Esempio
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";"-";"+")');
Questo esempio determina il valore più piccolo in un intervallo A1:F10 sul foglio attivo
TXLSWorkbook e TXLSXWorkbook possono confrontare i risultati delle formule memorizzati con risultati appena valutati, senza sostituire la cache memorizzata
function CalculateAndVerify: Integer; overload;
function CalculateAndVerify(out Mismatches: TArray<TXLSVerifyMismatch>): Integer; overload;
Il valore restituito è il numero di discordanze. Ogni record contiene SheetIndex, SheetName, Row e Col a base uno, Expected, Actual e Formula. Le formule volatili, le celle delle tabelle dati, le formule senza risultato memorizzato e le formule non valutabili vengono saltate
MismatchCount := Workbook.CalculateAndVerify(Mismatches);
for I := 0 to MismatchCount - 1 do
Log(Mismatches[I].SheetName, Mismatches[I].Row,
Mismatches[I].Col, Mismatches[I].Expected, Mismatches[I].Actual);