fpspreadsheet: Add IFERROR() function (https://forum.lazarus.freepascal.org/index.php/topic,65991.0.html). Does not work in xls.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@9175 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
parent
8b5044137b
commit
211b9489e3
@ -2034,6 +2034,26 @@ begin
|
|||||||
Result := BooleanResult(true);
|
Result := BooleanResult(true);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure fpsIFERROR(var Result: TsExpressionResult; const Args: TsExprParameterArray);
|
||||||
|
// IFERROR( value; value_if_error )
|
||||||
|
// If "value" is an error value (#N/A, #VALUE!, #REF!, #DIV/0!, #NUM!, #NAME?
|
||||||
|
// or #NULL), this function will return Args[1]. Otherwise, it will return Args[0].
|
||||||
|
var
|
||||||
|
cell: PCell;
|
||||||
|
begin
|
||||||
|
if (Args[0].ResultType = rtCell) then
|
||||||
|
begin
|
||||||
|
cell := ArgToCell(Args[0]);
|
||||||
|
if (cell <> nil) and (cell^.ContentType = cctError) and (cell^.ErrorValue <= errArgError)
|
||||||
|
then Result := Args[1]
|
||||||
|
else result := Args[0];
|
||||||
|
end else
|
||||||
|
if (Args[0].ResultType = rtError) then
|
||||||
|
Result := Args[1]
|
||||||
|
else
|
||||||
|
Result := Args[0];
|
||||||
|
end;
|
||||||
|
|
||||||
procedure fpsISLOGICAL(var Result: TsExpressionResult; const Args: TsExprParameterArray);
|
procedure fpsISLOGICAL(var Result: TsExpressionResult; const Args: TsExprParameterArray);
|
||||||
// ISLOGICAL( value )
|
// ISLOGICAL( value )
|
||||||
var
|
var
|
||||||
@ -2513,6 +2533,8 @@ begin
|
|||||||
AddFunction(cat, 'ISREF', 'B', '?', INT_EXCEL_SHEET_FUNC_ISREF, @fpsISREF);
|
AddFunction(cat, 'ISREF', 'B', '?', INT_EXCEL_SHEET_FUNC_ISREF, @fpsISREF);
|
||||||
AddFunction(cat, 'ISTEXT', 'B', '?', INT_EXCEL_SHEET_FUNC_ISTEXT, @fpsISTEXT);
|
AddFunction(cat, 'ISTEXT', 'B', '?', INT_EXCEL_SHEET_FUNC_ISTEXT, @fpsISTEXT);
|
||||||
|
|
||||||
|
AddFunction(cat, 'IFERROR', 'S', '?S', INT_EXCEL_SHEET_FUNC_UNKNOWN, @fpsIFERROR); // not supported by .xls
|
||||||
|
|
||||||
// Lookup / reference functions
|
// Lookup / reference functions
|
||||||
cat := bcLookup;
|
cat := bcLookup;
|
||||||
AddFunction(cat, 'ADDRESS', 'S', 'IIibs',INT_EXCEL_SHEET_FUNC_ADDRESS, @fpsADDRESS);
|
AddFunction(cat, 'ADDRESS', 'S', 'IIibs',INT_EXCEL_SHEET_FUNC_ADDRESS, @fpsADDRESS);
|
||||||
|
@ -272,6 +272,7 @@ const
|
|||||||
|
|
||||||
INT_EXCEL_SHEET_FUNC_HYPERLINK = 359; // BIFF8 only
|
INT_EXCEL_SHEET_FUNC_HYPERLINK = 359; // BIFF8 only
|
||||||
|
|
||||||
|
INT_EXCEL_SHEET_FUNC_UNKNOWN = 255; // not available in any BIFF
|
||||||
|
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
Loading…
Reference in New Issue
Block a user