UPDATE: Adds missing information functions (#514)

* UPDATE: Adds missing information functions

Implements N, CELL, INFO and SHEETS

Note that INFO is implemented as N/IMPL! and CELL is not implemented
for those values that is not implemented in Excel for the web

* FIX: Copilot fixes

* FIX: Make clippy happy
This commit is contained in:
Nicolás Hatcher Andrés
2025-11-06 18:58:39 +01:00
committed by GitHub
parent 3d265bba27
commit d4f69f2ec2
4 changed files with 181 additions and 2 deletions

View File

@@ -134,6 +134,11 @@ pub enum Function {
Sheet,
Type,
Sheets,
N,
Cell,
Info,
// Lookup and reference
Hlookup,
Index,
@@ -308,7 +313,7 @@ pub enum Function {
}
impl Function {
pub fn into_iter() -> IntoIter<Function, 252> {
pub fn into_iter() -> IntoIter<Function, 256> {
[
Function::And,
Function::False,
@@ -562,6 +567,10 @@ impl Function {
Function::Combin,
Function::Combina,
Function::Sumsq,
Function::N,
Function::Cell,
Function::Info,
Function::Sheets,
]
.into_iter()
}
@@ -614,6 +623,7 @@ impl Function {
Function::Decimal => "_xlfn.DECIMAL".to_string(),
Function::Arabic => "_xlfn.ARABIC".to_string(),
Function::Combina => "_xlfn.COMBINA".to_string(),
Function::Sheets => "_xlfn.SHEETS".to_string(),
_ => self.to_string(),
}
@@ -894,6 +904,11 @@ impl Function {
"SUBTOTAL" => Some(Function::Subtotal),
"N" => Some(Function::N),
"CELL" => Some(Function::Cell),
"INFO" => Some(Function::Info),
"SHEETS" | "_XLFN.SHEETS" => Some(Function::Sheets),
_ => None,
}
}
@@ -1154,6 +1169,11 @@ impl fmt::Display for Function {
Function::Combin => write!(f, "COMBIN"),
Function::Combina => write!(f, "COMBINA"),
Function::Sumsq => write!(f, "SUMSQ"),
Function::N => write!(f, "N"),
Function::Cell => write!(f, "CELL"),
Function::Info => write!(f, "INFO"),
Function::Sheets => write!(f, "SHEETS"),
}
}
}
@@ -1434,6 +1454,10 @@ impl Model {
Function::Combin => self.fn_combin(args, cell),
Function::Combina => self.fn_combina(args, cell),
Function::Sumsq => self.fn_sumsq(args, cell),
Function::N => self.fn_n(args, cell),
Function::Cell => self.fn_cell(args, cell),
Function::Info => self.fn_info(args, cell),
Function::Sheets => self.fn_sheets(args, cell),
}
}
}