xlnt - community edition
page_setup.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 <xlnt/xlnt_config.hpp>
29 #include <xlnt/utils/optional.hpp>
30 #include <xlnt/utils/value_with_default.h>
31 
32 namespace xlnt {
33 
34 namespace detail {
35 
36 class xlsx_producer;
37 
38 } // namespace detail
39 
43 enum class orientation
44 {
45  default_orientation,
46  portrait,
47  landscape
48 };
49 
53 enum class page_break
54 {
55  none = 0,
56  row = 1,
57  column = 2
58 };
59 
63 enum class paper_size
64 {
65  letter = 1,
66  letter_small = 2,
67  tabloid = 3,
68  ledger = 4,
69  legal = 5,
70  statement = 6,
71  executive = 7,
72  a3 = 8,
73  a4 = 9,
74  a4_small = 10,
75  a5 = 11
76 };
77 
82 enum class sheet_state
83 {
84  visible,
85  hidden,
86  very_hidden
87 };
88 
92 struct XLNT_API page_setup
93 {
94 public:
98  page_setup();
99 
104 
109 
114 
118  void sheet_state(xlnt::sheet_state sheet_state);
119 
126 
130  void paper_size(xlnt::paper_size paper_size);
131 
135  bool has_paper_size() const;
136 
140  bool fit_to_page() const;
141 
145  void fit_to_page(bool fit_to_page);
146 
150  bool fit_to_height() const;
151 
155  void fit_to_height(bool fit_to_height);
156 
160  bool fit_to_width() const;
161 
165  void fit_to_width(bool fit_to_width);
166 
171  void scale(unsigned int scale);
172 
177  unsigned int scale() const;
178 
182  bool has_scale() const;
183 
187  const std::string& rel_id() const;
188 
192  void rel_id(const std::string& val);
193 
197  bool has_rel_id() const;
198 
211 
212  bool operator==(const page_setup &rhs) const;
213 
214  bool operator!=(const page_setup &rhs) const;
215 
216 private:
217  friend class xlnt::detail::xlsx_producer;
218 
222  std::string rel_id_;
223 
227  xlnt::page_break break_;
228 
232  xlnt::sheet_state sheet_state_;
233 
238 
242  bool fit_to_page_;
243 
247  bool fit_to_height_;
248 
252  bool fit_to_width_;
253 
258 };
259 
260 } // namespace xlnt
orientation
The orientation of the worksheet when it is printed.
Definition: page_setup.hpp:43
xlnt::optional< std::size_t > horizontal_dpi_
The horizontal dpi
Definition: page_setup.hpp:206
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.
Encapsulates a value with a default value
Definition: value_with_default.h:59
bool operator==(std::nullptr_t, const cell &cell)
Returns true if this cell is uninitialized.
paper_size
The possible paper sizes for printing.
Definition: page_setup.hpp:63
sheet_state
Defines how a worksheet appears in the workbook. A workbook must have at least one sheet which is vis...
Definition: page_setup.hpp:82
xlnt::optional< std::size_t > vertical_dpi_
The vertical dpi
Definition: page_setup.hpp:210
Describes how a worksheet will be converted into a page during printing.
Definition: page_setup.hpp:92
xlnt::optional< xlnt::orientation > orientation_
The orientation
Definition: page_setup.hpp:202
page_break
The types of page breaks.
Definition: page_setup.hpp:53