Skip to main content

ironcalc_base/
constants.rs

1#![deny(missing_docs)]
2
3/// Default column width in pixels
4pub(crate) const DEFAULT_COLUMN_WIDTH: f64 = 90.0;
5
6/// Default row height in pixels
7pub(crate) const DEFAULT_ROW_HEIGHT: f64 = 25.0;
8
9/// A column width of Excel value `w` will result in `w * COLUMN_WIDTH_FACTOR` pixels
10pub const COLUMN_WIDTH_FACTOR: f64 = 9.0;
11
12/// A row height of Excel value `h` will result in `h * ROW_HEIGHT_FACTOR` pixels
13pub const ROW_HEIGHT_FACTOR: f64 = 1.5625; // 25.0 / 16.0
14
15/// Default window height in pixels
16pub(crate) const DEFAULT_WINDOW_HEIGHT: i64 = 600;
17
18/// Default window width in pixels
19pub(crate) const DEFAULT_WINDOW_WIDTH: i64 = 800;
20
21/// Maximum number of columns
22pub(crate) const LAST_COLUMN: i32 = 16_384;
23
24/// Maximum number of rows
25pub(crate) const LAST_ROW: i32 = 1_048_576;
26
27/// Excel uses 15 significant digits of precision for all numeric calculations.
28pub(crate) const EXCEL_PRECISION: usize = 15;
29
30/// 693_594 is computed as:
31/// NaiveDate::from_ymd(1900, 1, 1).num_days_from_ce() - 2
32/// The 2 days offset is because of Excel 1900 bug
33pub(crate) const EXCEL_DATE_BASE: i32 = 693_594;
34
35/// We do not support dates before 1899-12-31.
36pub(crate) const MINIMUM_DATE_SERIAL_NUMBER: i32 = 1;
37
38/// Excel can handle dates until the year 9999-12-31
39/// 2958465 is the number of days from 1900-01-01 to 9999-12-31
40pub(crate) const MAXIMUM_DATE_SERIAL_NUMBER: i32 = 2_958_465;
41
42#[cfg(test)]
43mod tests {
44    use super::*;
45    #[test]
46    fn test_constants() {
47        assert_eq!(COLUMN_WIDTH_FACTOR * 10.0, DEFAULT_COLUMN_WIDTH);
48        assert_eq!(ROW_HEIGHT_FACTOR * 16.0, DEFAULT_ROW_HEIGHT);
49    }
50}