xlnt - community edition
style.hpp
1 // Copyright (c) 2014-2022 Thomas Fussell
2 // Copyright (c) 2010-2015 openpyxl
3 // Copyright (c) 2024-2026 xlnt-community
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining a copy
6 // of this software and associated documentation files (the "Software"), to deal
7 // in the Software without restriction, including without limitation the rights
8 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 // copies of the Software, and to permit persons to whom the Software is
10 // furnished to do so, subject to the following conditions:
11 //
12 // The above copyright notice and this permission notice shall be included in
13 // all copies or substantial portions of the Software.
14 //
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 // THE SOFTWARE
22 //
23 // @license: http://www.opensource.org/licenses/mit-license.php
24 // @author: see AUTHORS file
25 
26 #pragma once
27 
28 #include <string>
29 
30 #include <xlnt/xlnt_config.hpp>
31 #include <xlnt/utils/optional.hpp>
32 
33 namespace xlnt {
34 
35 class alignment;
36 class border;
37 class cell;
38 class fill;
39 class font;
40 class number_format;
41 class protection;
42 
43 namespace detail {
44 
45 struct style_impl;
46 struct stylesheet;
47 class xlsx_consumer;
48 
49 } // namespace detail
50 
55 class XLNT_API style
56 {
57 public:
61  style() = delete;
62 
66  style(const style &other) = default;
67 
71  std::string name() const;
72 
77  style name(const std::string &name);
78 
82  bool hidden() const;
83 
90  style hidden(bool value);
91 
96  bool custom_builtin() const;
97 
103  std::size_t builtin_id() const;
104 
108  bool builtin() const;
109 
110  // Formatting (xf) components
111 
116  class alignment alignment() const;
117 
121  bool has_alignment() const;
122 
127  bool alignment_applied() const;
128 
135  style alignment(const xlnt::alignment &new_alignment, optional<bool> applied = {});
136 
141  class border border() const;
142 
146  bool has_border() const;
147 
151  bool border_applied() const;
152 
159  style border(const xlnt::border &new_border, optional<bool> applied = {});
160 
165  class fill fill() const;
166 
170  bool has_fill() const;
171 
175  bool fill_applied() const;
176 
182  style fill(const xlnt::fill &new_fill, optional<bool> applied = {});
183 
188  class font font() const;
189 
193  bool has_font() const;
194 
198  bool font_applied() const;
199 
206  style font(const xlnt::font &new_font, optional<bool> applied = {});
207 
212  class number_format number_format() const;
213 
217  bool has_number_format() const;
218 
222  bool number_format_applied() const;
223 
230  style number_format(const xlnt::number_format &new_number_format, optional<bool> applied = {});
231 
236  class protection protection() const;
237 
241  bool has_protection() const;
242 
246  bool protection_applied() const;
247 
254  style protection(const xlnt::protection &new_protection, optional<bool> applied = {});
255 
259  bool pivot_button() const;
260 
265  void pivot_button(bool show);
266 
270  bool quote_prefix() const;
271 
277  void quote_prefix(bool quote);
278 
282  bool operator==(const style &other) const;
283 
287  bool operator!=(const style &other) const;
288 
289 private:
290  friend struct detail::stylesheet;
291  friend class detail::xlsx_consumer;
292 
296  style(detail::style_impl *d);
297 
301  detail::style_impl *d_ = nullptr;
302 };
303 
304 } // namespace xlnt
Enumerates the possible types a cell can be determined by it&#39;s current value.
Definition: cell.hpp:36
bool operator!=(std::nullptr_t, const cell &cell)
Returns true if this cell is initialized.
Describes the font style of a particular cell.
Definition: font.hpp:43
Describes the fill style of a particular cell.
Definition: fill.hpp:299
Describes the border style of a particular cell.
Definition: border.hpp:91
bool operator==(std::nullptr_t, const cell &cell)
Returns true if this cell is uninitialized.
Describes the number formatting applied to text and numbers within a certain cell.
Definition: number_format.hpp:40
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:36
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:55