pub fn serialize_chrono_naive_to_excel<S>(
    datetime: impl IntoExcelDateTime,
    serializer: S
) -> Result<S::Ok, S::Error>
where S: Serializer,
Available on crate feature serde only.
Expand description

Serialize a Chrono naive date/time to an Excel value.

This is a helper function for serializing Chrono naive date/time fields using Serde. “Naive” in the Chrono sense means that the dates/times don’t have timezone information, like Excel.

The function works for the following types:

Option<T> Chrono types can be handled with serialize_chrono_option_naive_to_excel().

See Working with Serde for more information about serialization with rust_xlsxwriter.

§Errors

§Examples

Example of a serializable struct with a Chrono Naive value with a helper function.

use rust_xlsxwriter::utility::serialize_chrono_naive_to_excel;
use serde::Serialize;

fn main() {
    #[derive(Serialize)]
    struct Student {
        full_name: String,

        #[serde(serialize_with = "serialize_chrono_naive_to_excel")]
        birth_date: NaiveDate,

        id_number: u32,
    }
}