Working with formulas
Formulas are stored in worksheet cells with <f/>. The cached value from the last calculation, when present, is stored in <v/>.
Formulas are SpreadsheetML expressions. They can contain constants, arithmetic and comparison operators, cell references, named ranges, and function calls such as SUM(C6:C10).
Formula markup
<c r="A6">
<f>SUM(A1:A5)</f>
<v>15</v>
</c>
The formula text is not evaluated by ooxmlsdk. Spreadsheet applications may recalculate it when the workbook is opened. If you edit formula inputs or formula text, make sure cached values and calculation metadata are still appropriate for your use case.
The generated schema type for <f/> is CellFormula. The cached <v/> result is optional; omitting it leaves recalculation to the spreadsheet application. Keeping an old cached value after changing a formula can display stale data in software that trusts the cache.
Rust workflow
Use the worksheet traversal pattern to find cells that contain <f/> and report both the formula text and any cached value:
#![allow(unused)] fn main() { pub fn get_formula_cells(path: &Path) -> Result<Vec<FormulaCell>, Box<dyn std::error::Error>> { let document = SpreadsheetDocument::new_from_file_with_settings(path, lazy_settings())?; let workbook_part = document.workbook_part()?; let Some(first_sheet) = workbook_part.worksheet_parts(&document).next() else { return Ok(Vec::new()); }; let worksheet_xml = first_sheet.data_as_str(&document)?.unwrap_or_default(); Ok(extract_formula_cells(worksheet_xml)) } }
For write paths, update only the intended <f/> and cached <v/> nodes, and decide whether to remove or refresh the calculation chain. ooxmlsdk does not calculate formulas; it preserves the package data you write.