Crate spreadsheet_ods_formula
source ·Expand description
This library provides functions that map to ODS-functions.
use spreadsheet_ods::{cell, CellRef};
use spreadsheet_ods_formula::{ formula, of};
let f = formula(of::sin(cell!(0,0)));
assert_eq!(f, "of:=SIN([.A1])");
All functions use traits to somewhat constrain the allowed parameter-types. There are quite a lot of traits to map the possible parameter types of ods-functions. By the nature of spreadsheets this is a rather loose mapping anyway.
-
Basic types ixx, uxx, bool, str, String and
Cow<str>
have the appropriate traits. The common operators are overloaded too. With the caveat that the first parameter must be created via the num() function. -
Expressions in parentheses must use the p()-function.
use spreadsheet_ods_formula::{formula, num, of, p};
let f = formula(num(33) * p(of::sqrt(2) + of::sqrt(3)));
- CellRef and CellRange are imported from spreadsheet-ods. There is also a cell!() macro.
use spreadsheet_ods::cell;
use spreadsheet_ods_formula::{formula};
let f = formula(cell!(0, 0));
println!("{}", f);
let f = formula(cell!("Table1" => 4, 4));
println!("{}", f);
let f = formula(cell!(0, 0, 4, 4));
println!("{}", f);
- ODS operators are mapped with the AnyOp, TextOp, NumberOp, LogicalOp and ReferenceOp traits.
use spreadsheet_ods::cell;
use spreadsheet_ods_formula::{formula};
use spreadsheet_ods_formula::{ReferenceOp};
let f = formula(cell!(0, 0, 4, 4).refcat(cell!(8, 8, 12, 12)));
println!("{}", f);
- Tuples are used for Sequences. They are formatted as inline-arrays.
use spreadsheet_ods::cell;
use spreadsheet_ods_formula::{formula, of};
let f = formula(of::networkdays__(
cell!(5, 5),
cell!(9, 9),
(9, 9, 9),
(0, 0, 0, 0, 0, 1, 0),
));
- FMatrix and FArray for inline arrays and matrizes.
use spreadsheet_ods::cell;
use spreadsheet_ods_formula::{FArray, formula, of};
let f = formula(of::networkdays__(
cell!(5, 5),
cell!(9, 9),
FArray([9, 9, 9]),
FArray([0, 0, 0, 0, 0, 1, 0]),
));
Modules§
- Bitwise functions.
- Comparison operators as functions.
- Functions for complex numbers.
- Conversion functions.
- Date functions
- Database functions.
- External access
- Financial functions.
- Information functions.
- Logical functions.
- Data lookup functions.
- Mathematical functions.
- Matrix functions.
- All functions in one module, and also all families of functions.
- Basic operators as functions.
- The traits for this crate. And the function p() for parentheses.
- Rounding functions.
- Statistical functions.
- Text functions.
- Byte-based text functions.
Structs§
- Array.
- Filter/search
- Matrix value.
- An expression in parentheses. Use p() to create one.
Enums§
- Filter criteria.
Traits§
- Trait for any part of the formula.
- Comparision operators
- Array parameter.
- A cell range containing headers and filters.
- Filter/Search criterion.
- Alias for a cell reference. A cell range containing headers and a data set.
- A date/time parameter.
- A field denominator for a db.
- Logical parameter.
- Operations on boolean-like values.
- Matrix parameter.
- Numeric parameter.
- Operations on number-like values.
- Number or Array parameter.
- Reference parameter.
- Operations on references.
- Reference or Array parameter.
- A single scalar value.
- Sequence of values.
- Text parameter.
- Operations on text-like values.
- Text or Number parameter.
- Reference or Text parameter.
Functions§
- Creates a formula from any formula expression.
- Creates a formula-number from a rust number literal.
- Creates an expression in parentheses.