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§
- bit
- Bitwise functions.
- cmp
- Comparison operators as functions.
- complex
- Functions for complex numbers.
- conv
- Conversion functions.
- date
- Date functions
- db
- Database functions.
- ext
- External access
- fin
- Financial functions.
- info
- Information functions.
- logic
- Logical functions.
- lookup
- Data lookup functions.
- math
- Mathematical functions.
- matrix
- Matrix functions.
- of
- All functions in one module, and also all families of functions.
- op
- Basic operators as functions.
- prelude
- The traits for this crate. And the function p() for parentheses.
- round
- Rounding functions.
- stat
- Statistical functions.
- text
- Text functions.
- textb
- Byte-based text functions.
Structs§
- FArray
- Array.
- FCriterion
- Filter/search
- FMatrix
- Matrix value.
- FParentheses
- An expression in parentheses. Use p() to create one.
Enums§
- Criterion
Cmp - Filter criteria.
Traits§
- Any
- Trait for any part of the formula.
- AnyOp
- Comparision operators
- Array
- Array parameter.
- Criteria
- A cell range containing headers and filters.
- Criterion
- Filter/Search criterion.
- Database
- Alias for a cell reference. A cell range containing headers and a data set.
- Date
Time - A date/time parameter.
- Field
- A field denominator for a db.
- Logical
- Logical parameter.
- Logical
Op - Operations on boolean-like values.
- Matrix
- Matrix parameter.
- Number
- Numeric parameter.
- Number
Op - Operations on number-like values.
- Number
OrArray - Number or Array parameter.
- Reference
- Reference parameter.
- Reference
Op - Operations on references.
- Reference
OrArray - Reference or Array parameter.
- Scalar
- A single scalar value.
- Sequence
- Sequence of values.
- Text
- Text parameter.
- TextOp
- Operations on text-like values.
- Text
OrNumber - Text or Number parameter.
- Text
OrReference - Reference or Text parameter.