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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// SPDX-License-Identifier: MIT
//
// Copyright 2016-2026, Johann Tuffe.
//! An example of deserializing spreadsheet rows into a named struct.
//!
//! Compared with `deserialize_range`, which uses an anonymous tuple, this
//! example demonstrates how to deserialize spreadsheet data into a named struct
//! derived with [`serde::Deserialize`] and how to collect all rows in a single
//! call.
//!
//! [`RangeDeserializerBuilder::with_deserialize_headers`] reads the field names
//! directly from the struct definition, so the column order in the spreadsheet
//! does not need to match the field order in the struct.
//!
//! The sample Excel file `temperature.xlsx` contains a single sheet named
//! "Sheet1" with the following data:
//!
//! ```text
//! ____________________________________________
//! | || | |
//! | || A | B |
//! |_________||________________|________________|
//! | 1 || label | value |
//! |_________||________________|________________|
//! | 2 || celsius | 22.2222 |
//! |_________||________________|________________|
//! | 3 || fahrenheit | 72 |
//! |_________||________________|________________|
//! |_ _________________________________|
//! \ Sheet1 /
//! ------
//! ```
//!
//! Next: `deserialize_flatten` — capturing extra columns into a `HashMap`
//! with `#[serde(flatten)]`.
use ;
use Deserialize;