make xlookup function like excel

This commit is contained in:
2026-01-23 13:35:50 -07:00
parent 8d3f003427
commit 69c7ebf24b
3 changed files with 5 additions and 5 deletions

View File

@@ -788,7 +788,7 @@ fn xlookup_function() {
grid.set_cell("A1", "Sarah".to_string());
grid.set_cell("C0", 31.);
grid.set_cell("C1", 41.);
grid.set_cell("B0", "=xlookup(A:A,\"Bobby\",C:C)".to_string());
grid.set_cell("B0", "=xlookup(\"Bobby\",A:A,C:C)".to_string());
let cell = grid.get_cell("B0").as_ref().expect("Just set the cell");
let res = grid.evaluate(&cell.to_string());
assert!(res.is_ok());

View File

@@ -104,13 +104,13 @@ impl<'a> CallbackContext<'a> {
functions.insert(
"xlookup".to_string(),
Function::new(|arg| {
let expected = vec![ValueType::Tuple, ValueType::String, ValueType::Tuple];
let expected = vec![ValueType::String, ValueType::Tuple, ValueType::Tuple];
if arg.is_tuple() {
let args = arg.as_tuple()?;
if args.len() == 3 {
let lookup_array = &args[0];
let lookup_value = &args[1];
let lookup_value = &args[0];
let lookup_array = &args[1];
let return_array = &args[2];
if lookup_array.is_tuple() && return_array.is_tuple() {