umya-spreadsheet 3.0.0

umya-spreadsheet is a library written in pure Rust to read and write xlsx file.
Documentation
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
// a:clrScheme
use std::io::Cursor;

use quick_xml::{
    Reader,
    Writer,
    events::{
        BytesStart,
        Event,
    },
};

use super::{
    super::StringValue,
    Color2Type,
};
use crate::{
    reader::driver::{
        get_attribute,
        set_string_from_xml,
        xml_read_loop,
    },
    writer::driver::{
        write_end_tag,
        write_start_tag,
    },
};

#[derive(Clone, Default, Debug)]
pub struct ColorScheme {
    name:      StringValue,
    accent1:   Color2Type,
    accent2:   Color2Type,
    accent3:   Color2Type,
    accent4:   Color2Type,
    accent5:   Color2Type,
    accent6:   Color2Type,
    dk1:       Color2Type,
    dk2:       Color2Type,
    fol_hlink: Color2Type,
    hlink:     Color2Type,
    lt1:       Color2Type,
    lt2:       Color2Type,
}

impl ColorScheme {
    #[inline]
    #[must_use]
    pub fn name(&self) -> &str {
        self.name.value_str()
    }

    #[inline]
    #[must_use]
    #[deprecated(since = "3.0.0", note = "Use name()")]
    pub fn get_name(&self) -> &str {
        self.name()
    }

    #[inline]
    pub fn set_name<S: Into<String>>(&mut self, value: S) -> &mut Self {
        self.name.set_value(value);
        self
    }

    #[inline]
    #[must_use]
    pub fn accent1(&self) -> &Color2Type {
        &self.accent1
    }

    #[inline]
    #[must_use]
    #[deprecated(since = "3.0.0", note = "Use accent1()")]
    pub fn get_accent1(&self) -> &Color2Type {
        self.accent1()
    }

    #[inline]
    pub fn accent1_mut(&mut self) -> &mut Color2Type {
        &mut self.accent1
    }

    #[inline]
    #[deprecated(since = "3.0.0", note = "Use accent1_mut()")]
    pub fn get_accent1_mut(&mut self) -> &mut Color2Type {
        self.accent1_mut()
    }

    #[inline]
    pub fn set_accent1(&mut self, value: Color2Type) -> &mut Self {
        self.accent1 = value;
        self
    }

    #[inline]
    #[must_use]
    pub fn accent2(&self) -> &Color2Type {
        &self.accent2
    }

    #[inline]
    #[must_use]
    #[deprecated(since = "3.0.0", note = "Use accent2()")]
    pub fn get_accent2(&self) -> &Color2Type {
        self.accent2()
    }

    #[inline]
    pub fn accent2_mut(&mut self) -> &mut Color2Type {
        &mut self.accent2
    }

    #[inline]
    #[deprecated(since = "3.0.0", note = "Use accent2_mut()")]
    pub fn get_accent2_mut(&mut self) -> &mut Color2Type {
        self.accent2_mut()
    }

    #[inline]
    pub fn set_accent2(&mut self, value: Color2Type) -> &mut Self {
        self.accent2 = value;
        self
    }

    #[inline]
    #[must_use]
    pub fn accent3(&self) -> &Color2Type {
        &self.accent3
    }

    #[inline]
    #[must_use]
    #[deprecated(since = "3.0.0", note = "Use accent3()")]
    pub fn get_accent3(&self) -> &Color2Type {
        self.accent3()
    }

    #[inline]
    pub fn accent3_mut(&mut self) -> &mut Color2Type {
        &mut self.accent3
    }

    #[inline]
    #[deprecated(since = "3.0.0", note = "Use accent3_mut()")]
    pub fn get_accent3_mut(&mut self) -> &mut Color2Type {
        self.accent3_mut()
    }

    #[inline]
    pub fn set_accent3(&mut self, value: Color2Type) -> &mut Self {
        self.accent3 = value;
        self
    }

    #[inline]
    #[must_use]
    pub fn accent4(&self) -> &Color2Type {
        &self.accent4
    }

    #[inline]
    #[must_use]
    #[deprecated(since = "3.0.0", note = "Use accent4()")]
    pub fn get_accent4(&self) -> &Color2Type {
        self.accent4()
    }

    #[inline]
    pub fn accent4_mut(&mut self) -> &mut Color2Type {
        &mut self.accent4
    }

    #[inline]
    #[deprecated(since = "3.0.0", note = "Use accent4_mut()")]
    pub fn get_accent4_mut(&mut self) -> &mut Color2Type {
        self.accent4_mut()
    }

    #[inline]
    pub fn set_accent4(&mut self, value: Color2Type) -> &mut Self {
        self.accent4 = value;
        self
    }

    #[inline]
    #[must_use]
    pub fn accent5(&self) -> &Color2Type {
        &self.accent5
    }

    #[inline]
    #[must_use]
    #[deprecated(since = "3.0.0", note = "Use accent5()")]
    pub fn get_accent5(&self) -> &Color2Type {
        self.accent5()
    }

    #[inline]
    pub fn accent5_mut(&mut self) -> &mut Color2Type {
        &mut self.accent5
    }

    #[inline]
    #[deprecated(since = "3.0.0", note = "Use accent5_mut()")]
    pub fn get_accent5_mut(&mut self) -> &mut Color2Type {
        self.accent5_mut()
    }

    #[inline]
    pub fn set_accent5(&mut self, value: Color2Type) -> &mut Self {
        self.accent5 = value;
        self
    }

    #[inline]
    #[must_use]
    pub fn accent6(&self) -> &Color2Type {
        &self.accent6
    }

    #[inline]
    #[must_use]
    #[deprecated(since = "3.0.0", note = "Use accent6()")]
    pub fn get_accent6(&self) -> &Color2Type {
        self.accent6()
    }

    #[inline]
    pub fn accent6_mut(&mut self) -> &mut Color2Type {
        &mut self.accent6
    }

    #[inline]
    #[deprecated(since = "3.0.0", note = "Use accent6_mut()")]
    pub fn get_accent6_mut(&mut self) -> &mut Color2Type {
        self.accent6_mut()
    }

    #[inline]
    pub fn set_accent6(&mut self, value: Color2Type) -> &mut Self {
        self.accent6 = value;
        self
    }

    #[inline]
    #[must_use]
    pub fn dk1(&self) -> &Color2Type {
        &self.dk1
    }

    #[inline]
    #[must_use]
    #[deprecated(since = "3.0.0", note = "Use dk1()")]
    pub fn get_dk1(&self) -> &Color2Type {
        self.dk1()
    }

    #[inline]
    pub fn dk1_mut(&mut self) -> &mut Color2Type {
        &mut self.dk1
    }

    #[inline]
    #[deprecated(since = "3.0.0", note = "Use dk1_mut()")]
    pub fn get_dk1_mut(&mut self) -> &mut Color2Type {
        self.dk1_mut()
    }

    #[inline]
    pub fn set_dk1(&mut self, value: Color2Type) -> &mut Self {
        self.dk1 = value;
        self
    }

    #[inline]
    #[must_use]
    pub fn dk2(&self) -> &Color2Type {
        &self.dk2
    }

    #[inline]
    #[must_use]
    #[deprecated(since = "3.0.0", note = "Use dk2()")]
    pub fn get_dk2(&self) -> &Color2Type {
        self.dk2()
    }

    #[inline]
    pub fn dk2_mut(&mut self) -> &mut Color2Type {
        &mut self.dk2
    }

    #[inline]
    #[deprecated(since = "3.0.0", note = "Use dk2_mut()")]
    pub fn get_dk2_mut(&mut self) -> &mut Color2Type {
        self.dk2_mut()
    }

    #[inline]
    pub fn set_dk2(&mut self, value: Color2Type) -> &mut Self {
        self.dk2 = value;
        self
    }

    #[inline]
    #[must_use]
    pub fn fol_hlink(&self) -> &Color2Type {
        &self.fol_hlink
    }

    #[inline]
    #[must_use]
    #[deprecated(since = "3.0.0", note = "Use fol_hlink()")]
    pub fn get_fol_hlink(&self) -> &Color2Type {
        self.fol_hlink()
    }

    #[inline]
    pub fn fol_hlink_mut(&mut self) -> &mut Color2Type {
        &mut self.fol_hlink
    }

    #[inline]
    #[deprecated(since = "3.0.0", note = "Use fol_hlink_mut()")]
    pub fn get_fol_hlink_mut(&mut self) -> &mut Color2Type {
        self.fol_hlink_mut()
    }

    #[inline]
    pub fn set_fol_hlink(&mut self, value: Color2Type) -> &mut Self {
        self.fol_hlink = value;
        self
    }

    #[inline]
    #[must_use]
    pub fn hlink(&self) -> &Color2Type {
        &self.hlink
    }

    #[inline]
    #[must_use]
    #[deprecated(since = "3.0.0", note = "Use hlink()")]
    pub fn get_hlink(&self) -> &Color2Type {
        self.hlink()
    }

    #[inline]
    pub fn hlink_mut(&mut self) -> &mut Color2Type {
        &mut self.hlink
    }

    #[inline]
    #[deprecated(since = "3.0.0", note = "Use hlink_mut()")]
    pub fn get_hlink_mut(&mut self) -> &mut Color2Type {
        self.hlink_mut()
    }

    #[inline]
    pub fn set_hlink(&mut self, value: Color2Type) -> &mut Self {
        self.hlink = value;
        self
    }

    #[inline]
    #[must_use]
    pub fn lt1(&self) -> &Color2Type {
        &self.lt1
    }

    #[inline]
    #[must_use]
    #[deprecated(since = "3.0.0", note = "Use lt1()")]
    pub fn get_lt1(&self) -> &Color2Type {
        self.lt1()
    }

    #[inline]
    pub fn lt1_mut(&mut self) -> &mut Color2Type {
        &mut self.lt1
    }

    #[inline]
    #[deprecated(since = "3.0.0", note = "Use lt1_mut()")]
    pub fn get_lt1_mut(&mut self) -> &mut Color2Type {
        self.lt1_mut()
    }

    #[inline]
    pub fn set_lt1(&mut self, value: Color2Type) -> &mut Self {
        self.lt1 = value;
        self
    }

    #[inline]
    #[must_use]
    pub fn lt2(&self) -> &Color2Type {
        &self.lt2
    }

    #[inline]
    #[must_use]
    #[deprecated(since = "3.0.0", note = "Use lt2()")]
    pub fn get_lt2(&self) -> &Color2Type {
        self.lt2()
    }

    #[inline]
    pub fn lt2_mut(&mut self) -> &mut Color2Type {
        &mut self.lt2
    }

    #[inline]
    #[deprecated(since = "3.0.0", note = "Use lt2_mut()")]
    pub fn get_lt2_mut(&mut self) -> &mut Color2Type {
        self.lt2_mut()
    }

    #[inline]
    pub fn set_lt2(&mut self, value: Color2Type) -> &mut Self {
        self.lt2 = value;
        self
    }

    #[inline]
    #[must_use]
    pub fn color_map(&self) -> Vec<String> {
        vec![
            self.lt1.val(),
            self.dk1.val(),
            self.lt2.val(),
            self.dk2.val(),
            self.accent1.val(),
            self.accent2.val(),
            self.accent3.val(),
            self.accent4.val(),
            self.accent5.val(),
            self.accent6.val(),
            self.hlink.val(),
            self.fol_hlink.val(),
        ]
    }

    #[inline]
    #[must_use]
    #[deprecated(since = "3.0.0", note = "Use color_map()")]
    pub fn get_color_map(&self) -> Vec<String> {
        self.color_map()
    }

    pub(crate) fn set_attributes<R: std::io::BufRead>(
        &mut self,
        reader: &mut Reader<R>,
        e: &BytesStart,
    ) {
        set_string_from_xml!(self, e, name, "name");

        xml_read_loop!(
            reader,
            Event::Start(ref e) => {
                match e.name().into_inner() {
                    b"a:accent1" => {
                        self.accent1.set_attributes(reader, e);
                    }
                    b"a:accent2" => {
                        self.accent2.set_attributes(reader, e);
                    }
                    b"a:accent3" => {
                        self.accent3.set_attributes(reader, e);
                    }
                    b"a:accent4" => {
                        self.accent4.set_attributes(reader, e);
                    }
                    b"a:accent5" => {
                        self.accent5.set_attributes(reader, e);
                    }
                    b"a:accent6" => {
                        self.accent6.set_attributes(reader, e);
                    }
                    b"a:dk1" => {
                        self.dk1.set_attributes(reader, e);
                    }
                    b"a:dk2" => {
                        self.dk2.set_attributes(reader, e);
                    }
                    b"a:folHlink" => {
                        self.fol_hlink.set_attributes(reader, e);
                    }
                    b"a:hlink" => {
                        self.hlink.set_attributes(reader, e);
                    }
                    b"a:lt1" => {
                        self.lt1.set_attributes(reader, e);
                    }
                    b"a:lt2" => {
                        self.lt2.set_attributes(reader, e);
                    }
                    _ => (),
                }
            },
            Event::End(ref e) => {
                if e.name().into_inner() == b"a:clrScheme" {
                    return
                }
            },
            Event::Eof => panic!("Error: Could not find {} end element", "a:clrScheme")
        );
    }

    pub(crate) fn write_to(&self, writer: &mut Writer<Cursor<Vec<u8>>>) {
        // a:clrScheme
        let mut attributes: crate::structs::AttrCollection = Vec::new();
        if self.name.has_value() {
            attributes.push(("name", self.name.value_str()).into());
        }
        write_start_tag(writer, "a:clrScheme", attributes, false);

        // a:dk1
        self.dk1.write_to_dk1(writer);

        // a:lt1
        self.lt1.write_to_lt1(writer);

        // a:dk2
        self.dk2.write_to_dk2(writer);

        // a:lt2
        self.lt2.write_to_lt2(writer);

        // a:accent1
        self.accent1.write_to_accent1(writer);

        // a:accent2
        self.accent2.write_to_accent2(writer);

        // a:accent3
        self.accent3.write_to_accent3(writer);

        // a:accent4
        self.accent4.write_to_accent4(writer);

        // a:accent5
        self.accent5.write_to_accent5(writer);

        // a:accent6
        self.accent6.write_to_accent6(writer);

        // a:hlink
        self.hlink.write_to_hlink(writer);

        // a:folHlink
        self.fol_hlink.write_to_fol_hlink(writer);

        write_end_tag(writer, "a:clrScheme");
    }
}