openprxl 0.1.0

A Rust spreadsheet library inspired by Python's openpyxl
Documentation
//! Number format support.

/// A custom or built-in number format.
#[derive(Debug, Clone, Default, PartialEq, Eq, Hash)]
pub struct NumberFormat {
    pub code: String,
}

impl NumberFormat {
    pub fn new<S: Into<String>>(code: S) -> Self {
        Self { code: code.into() }
    }

    /// Built-in General format.
    pub fn general() -> Self {
        Self::new("General")
    }

    /// Built-in date format (`yyyy-mm-dd`).
    pub fn date() -> Self {
        Self::new("yyyy-mm-dd")
    }

    /// Built-in date-time format.
    pub fn date_time() -> Self {
        Self::new("yyyy-mm-dd hh:mm:ss")
    }

    /// Built-in percentage format.
    pub fn percentage() -> Self {
        Self::new("0%")
    }

    /// Built-in currency format.
    pub fn currency() -> Self {
        Self::new("\"$\"#,##0.00")
    }
}

impl<S: Into<String>> From<S> for NumberFormat {
    fn from(code: S) -> Self {
        Self::new(code)
    }
}