committed by
Nicolás Hatcher Andrés
parent
1053d00d22
commit
eb76d8dd23
@@ -24,11 +24,22 @@ impl Model {
|
||||
CalcResult::Number(f) => Ok(NumberOrArray::Number(f)),
|
||||
CalcResult::String(s) => match s.parse::<f64>() {
|
||||
Ok(f) => Ok(NumberOrArray::Number(f)),
|
||||
_ => Err(CalcResult::new_error(
|
||||
Error::VALUE,
|
||||
cell,
|
||||
"Expecting number".to_string(),
|
||||
)),
|
||||
_ => {
|
||||
let mut currencies = vec!["$", "€"];
|
||||
let currency = &self.locale.currency.symbol;
|
||||
if !currencies.iter().any(|e| e == currency) {
|
||||
currencies.push(currency);
|
||||
}
|
||||
// Try to parse as a formatted number (e.g., dates, currencies, percentages)
|
||||
if let Ok((v, _number_format)) = parse_formatted_number(&s, ¤cies) {
|
||||
return Ok(NumberOrArray::Number(v));
|
||||
}
|
||||
Err(CalcResult::new_error(
|
||||
Error::VALUE,
|
||||
cell,
|
||||
"Expecting number".to_string(),
|
||||
))
|
||||
}
|
||||
},
|
||||
CalcResult::Boolean(f) => {
|
||||
if f {
|
||||
|
||||
Reference in New Issue
Block a user