Closed fosdickio closed 7 months ago
All modified and coverable lines are covered by tests :white_check_mark:
Comparison is base (
d2bab66
) 90.36% compared to head (a4970e0
) 90.36%.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Summary
I'm adding a new public API endpoint to check whether a cell contains an error or formula. I found this missing when trying to work through an example to read in a workbook and do something simple (count the total number of cells, formulas, and errors). I'm adding an example to accompany it.
External Usage
I originally worked on this from a separate project and pulled in the dependency to
Cargo.toml
like so (similar toTironCalc
):
That's a nice idea but what you are doing here is better.
[dependencies] ironcalc = { git = "https://github.com/ironcalc/IronCalc", version = "0.1.0"}
I think you can drop the version (my mistake!)
From there, I was able to load a local
.xlsx
file and perform the operation on it (cargo run test.xlsx
).use ironcalc::import::load_model_from_xlsx; fn main() { let args: Vec<String> = std::env::args().collect(); if args.len() != 2 { panic!("Usage: {} <file.xlsx>", args[0]); } let file_name = &args[1]; let mut model = load_model_from_xlsx(file_name, "en", "UTC").unwrap(); model.evaluate(); let cells = model.get_all_cells(); let mut cells_count = 0; let mut formula_count = 0; let mut error_count = 0; for cell in cells { if model.cell_contains_formula(cell.index, cell.row, cell.column) { formula_count += 1; } else if model.cell_contains_error(cell.index, cell.row, cell.column) { error_count += 1; } cells_count += 1; } println!("Cell count: {}", cells_count); println!("Formula count: {}", formula_count); println!("Error count: {}", error_count); }
Other Considerations
I've moved this example into
base
, as it is an example mostly demonstrating functionality onironcalc_base::model::Model
.Testing
This code was ran locally and tested using
make tests
without error.
@nhatcher This is ready for review again based on your feedback. You might want to squash-and-merge this one, as there are quite a few small little changes.
Summary
I'm adding a new example to check whether a cell contains an error or formula. I found this missing when trying to work through an example to read in a workbook and do something simple (count the total number of cells, formulas, and errors).
External Usage
I originally worked on this from a separate project and pulled in the dependency to
Cargo.toml
like so (similar toTironCalc
):From there, I was able to load a local
.xlsx
file and perform the operation on it (cargo run test.xlsx
).Other Considerations
I've moved this example into
base
, as it is an example mostly demonstrating functionality onironcalc_base::model::Model
.Testing
This code was ran locally and tested using
make tests
without error.