1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Deserialize, Serialize)]
pub(crate) struct SheetFormatPr {
    #[serde(rename = "@defaultColWidth", skip_serializing_if = "Option::is_none")]
    default_col_width: Option<f64>,
    #[serde(rename = "@defaultRowHeight")]
    default_row_height: f64,
    #[serde(rename = "@customHeight", skip_serializing_if = "Option::is_none")]
    custom_height: Option<u8>,
    #[serde(rename = "@zeroHeight", skip_serializing_if = "Option::is_none")]
    zero_height: Option<u8>,
    #[serde(rename = "@outlineLevelCol", skip_serializing_if = "Option::is_none")]
    outline_level_col: Option<u8>,
    #[serde(rename(serialize = "@x14ac:dyDescent", deserialize = "@dyDescent"), skip_serializing_if = "Option::is_none")]
    x14ac_dy_descent: Option<f64>,
}

impl Default for SheetFormatPr {
    fn default() -> SheetFormatPr {
        SheetFormatPr {
            default_col_width: None,
            default_row_height: 15.0,
            custom_height: None,
            zero_height: None,
            outline_level_col: None,
            x14ac_dy_descent: None,
        }
    }
}

impl SheetFormatPr {
    pub(crate) fn set_default_row_height(&mut self, height: f64) {
        self.custom_height = Some(1);
        self.default_row_height = height;
    }

    pub(crate) fn get_default_row_height(&self) -> f64 {
        self.default_row_height
    }

    pub(crate) fn set_default_col_width(&mut self, width: f64) {
        self.custom_height = Some(1);
        self.default_col_width = Some(width);
    }

    pub(crate) fn get_default_col_width(&self) -> f64 {
        self.default_col_width.unwrap_or(8.11)
    }

    pub(crate) fn hide_unused_rows(&mut self, hide: bool) {
        self.zero_height = Some(hide as u8);
    }

    pub(crate) fn set_outline_level_col(&mut self, col_level: u8) {
        self.outline_level_col = Some(col_level)
    }
}