UPDATE: Adds FORMULATEXT for Steve

This commit is contained in:
Nicolás Hatcher
2024-11-27 20:07:00 +01:00
committed by Nicolás Hatcher Andrés
parent 8ed0ab25f6
commit 726fc1399d
5 changed files with 64 additions and 1 deletions

View File

@@ -293,4 +293,43 @@ 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(),
}
}
}
}