FIX: Adds some more tests fro FORMULATEXT

This commit is contained in:
Nicolás Hatcher
2024-11-27 21:30:41 +01:00
committed by Nicolás Hatcher Andrés
parent 65b959cb1c
commit d70ab85396
3 changed files with 71 additions and 41 deletions

View File

@@ -293,43 +293,4 @@ impl Model {
message: "Invalid name".to_string(),
}
}
pub(crate) fn fn_formulatext(&mut self, args: &[Node], cell: CellReferenceIndex) -> CalcResult {
if args.len() != 1 {
return CalcResult::new_args_number_error(cell);
}
if let CalcResult::Range { left, right } = self.evaluate_node_with_reference(&args[0], cell)
{
if left.sheet != right.sheet {
return CalcResult::Error {
error: Error::ERROR,
origin: cell,
message: "3D ranges not supported".to_string(),
};
}
if left.row != right.row && left.column != right.column {
// FIXME: Implicit intersection or dynamic arrays
return CalcResult::Error {
error: Error::VALUE,
origin: cell,
message: "argument must be a reference to a single cell".to_string(),
};
}
if let Ok(Some(f)) = self.get_cell_formula(left.sheet, left.row, left.column) {
CalcResult::String(f)
} else {
CalcResult::Error {
error: Error::NA,
origin: cell,
message: "Reference does not have a formula".to_string(),
}
}
} else {
CalcResult::Error {
error: Error::VALUE,
origin: cell,
message: "Argument must be a reference".to_string(),
}
}
}
}