xlnt
format.hpp
1 // Copyright (c) 2014-2022 Thomas Fussell
2 // Copyright (c) 2024 xlnt-community
3 //
4 // Permission is hereby granted, free of charge, to any person obtaining a copy
5 // of this software and associated documentation files (the "Software"), to deal
6 // in the Software without restriction, including without limitation the rights
7 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 // copies of the Software, and to permit persons to whom the Software is
9 // furnished to do so, subject to the following conditions:
10 //
11 // The above copyright notice and this permission notice shall be included in
12 // all copies or substantial portions of the Software.
13 //
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 // THE SOFTWARE
21 //
22 // @license: http://www.opensource.org/licenses/mit-license.php
23 // @author: see AUTHORS file
24 
25 #pragma once
26 
27 #include <cstddef>
28 #include <string>
29 
30 #include <xlnt/xlnt_config.hpp>
31 
32 namespace xlnt {
33 
34 class alignment;
35 class border;
36 class cell;
37 class fill;
38 class font;
39 class number_format;
40 class protection;
41 class style;
42 
43 template <typename T>
44 class optional;
45 
46 namespace detail {
47 
48 struct format_impl;
49 struct stylesheet;
50 class xlsx_producer;
51 class xlsx_consumer;
52 
53 } // namespace detail
54 
58 class XLNT_API format
59 {
60 public:
64  class alignment alignment() const;
65 
71  format alignment(const xlnt::alignment &new_alignment, xlnt::optional<bool> applied = {});
72 
77  bool alignment_applied() const;
78 
82  class border border() const;
83 
89  format border(const xlnt::border &new_border, xlnt::optional<bool> applied = {});
90 
94  bool border_applied() const;
95 
99  class fill fill() const;
100 
106  format fill(const xlnt::fill &new_fill, xlnt::optional<bool> applied = {});
107 
111  bool fill_applied() const;
112 
116  class font font() const;
117 
123  format font(const xlnt::font &new_font, xlnt::optional<bool> applied = {});
124 
128  bool font_applied() const;
129 
133  class number_format number_format() const;
134 
140  format number_format(const xlnt::number_format &new_number_format, xlnt::optional<bool> applied = {});
141 
145  bool number_format_applied() const;
146 
150  class protection protection() const;
151 
155  bool protection_applied() const;
156 
162  format protection(const xlnt::protection &new_protection, xlnt::optional<bool> applied = {});
163 
167  bool pivot_button() const;
168 
173  void pivot_button(bool show);
174 
178  bool quote_prefix() const;
179 
185  void quote_prefix(bool quote);
186 
190  bool has_style() const;
191 
195  void clear_style();
196 
200  format style(const std::string &name);
201 
205  format style(const class style &new_style);
206 
211  class style style();
212 
217  const class style style() const;
218 
219 private:
220  friend struct detail::stylesheet;
221  friend class detail::xlsx_producer;
222  friend class detail::xlsx_consumer;
223  friend class cell;
224 
228  format(detail::format_impl *d);
229 
233  detail::format_impl *d_;
234 };
235 
236 } // namespace xlnt
Enumerates the possible types a cell can be determined by it&#39;s current value.
Definition: cell.hpp:37
Describes the font style of a particular cell.
Definition: font.hpp:41
Describes the fill style of a particular cell.
Definition: fill.hpp:299
Describes the border style of a particular cell.
Definition: border.hpp:94
Describes a unit of data in a worksheet at a specific coordinate and its associated properties...
Definition: cell.hpp:84
Describes the number formatting applied to text and numbers within a certain cell.
Definition: number_format.hpp:41
Many settings in xlnt are allowed to not have a value set. This class encapsulates a value which may ...
Definition: format.hpp:44
Describes the formatting of a particular cell.
Definition: format.hpp:58
Alignment options that determine how text should be displayed within a cell.
Definition: alignment.hpp:63
Describes the protection style of a particular cell.
Definition: protection.hpp:38
Describes a style which has a name and can be applied to multiple individual formats. In Excel this is a "Cell Style".
Definition: style.hpp:56