fpspreadsheet: Fix formula MATCH for match_type 1.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@9388 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz 2024-07-17 14:33:12 +00:00
parent d7fad0c7b8
commit fe27d6ec34

View File

@ -2738,7 +2738,8 @@ procedure fpsMATCH(var Result: TsExpressionResult;
value. The array can be sorted in any order.)
match_type = -1: The MATCH function will find the smallest value that is
greater than or equal to value. You should be sure to sort your array in
descending order. }
descending order.
Return value is the 1-based index in the array. }
var
match_type: Integer;
searchString: String;
@ -2842,8 +2843,6 @@ begin
end;
if IsCol then
begin
if match_type = -1 then
begin
for r := r2 downto r1 do
if Matches(sheet.FindCell(r, c1)) then begin
@ -2851,30 +2850,12 @@ begin
exit;
end;
end else
begin
for r := r1 to r2 do
if Matches(sheet.FindCell(r, c1)) then begin
Result := IntegerResult(r - integer(r1) + 1);
exit;
end;
end;
end else
begin
if match_type = -1 then
begin
for c := c2 downto c1 do
if Matches(sheet.FindCell(r1, c)) then begin
Result := IntegerResult(c - Integer(c1) + 1);
exit;
end;
end else
begin
for c := c1 to c2 do
if Matches(sheet.FindCell(r1, c)) then begin
Result := IntegerResult(c - Integer(c1) + 1);
exit;
end;
end;
end;
// If the procedure gets here, not match has been found --> return error #N/A