search in horizontale

This commit is contained in:
El Mau 2022-02-09 11:12:23 -06:00
parent cf41711716
commit fd706d59ba
2 changed files with 16 additions and 13 deletions

Binary file not shown.

View File

@ -32,23 +32,23 @@ class ZAZFunctions(unohelper.Base, XZAZFunctions):
value = None
# ~ print('Columns', lookup_array.Columns.Count)
# ~ print('Rows', lookup_array.Rows.Count)
source = lookup_array.DataArray
target = return_array.DataArray
if search_mode == 1:
index = next((i for i, v in enumerate(source) if v[0] == lookup_value), None)
elif search_mode == -1:
index = next((i for i, v in enumerate(reversed(source)) if v[0] == lookup_value), None)
horizontal = False
if lookup_array.Columns.Count == 1:
source = tuple(map(lambda x: x[0], source))
else:
horizontal = True
source = source[0]
target = target[0]
if search_mode == -1:
source = tuple(reversed(source))
index = next((i for i, v in enumerate(source) if v == lookup_value), None)
if index is None:
if match_mode in (-1, 1, 2):
source = map(lambda x: x[0], source))
if search_mode == -1:
source = reversed(source)
source = tuple(source)
if match_mode == -1:
index = bisect.bisect_right(source, lookup_value)
value = (target[index - 1],)
@ -56,7 +56,10 @@ class ZAZFunctions(unohelper.Base, XZAZFunctions):
index = bisect.bisect_left(source, lookup_value)
value = (target[index],)
else:
value = (target[index],)
if horizontal:
value = ((target[index],),)
else:
value = (target[index],)
if value is None and if_not_found:
value = ((if_not_found,),)