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
| # Copyright (c) 2010-2024 openpyxl
|
| from openpyxl.descriptors.serialisable import Serialisable
| from openpyxl.descriptors import (
| Integer,
| Bool,
| Sequence,
| )
|
|
| class Break(Serialisable):
|
| tagname = "brk"
|
| id = Integer(allow_none=True)
| min = Integer(allow_none=True)
| max = Integer(allow_none=True)
| man = Bool(allow_none=True)
| pt = Bool(allow_none=True)
|
| def __init__(self,
| id=0,
| min=0,
| max=16383,
| man=True,
| pt=None,
| ):
| self.id = id
| self.min = min
| self.max = max
| self.man = man
| self.pt = pt
|
|
| class RowBreak(Serialisable):
|
| tagname = "rowBreaks"
|
| count = Integer(allow_none=True)
| manualBreakCount = Integer(allow_none=True)
| brk = Sequence(expected_type=Break, allow_none=True)
|
| __elements__ = ('brk',)
| __attrs__ = ("count", "manualBreakCount",)
|
| def __init__(self,
| count=None,
| manualBreakCount=None,
| brk=(),
| ):
| self.brk = brk
|
|
| def __bool__(self):
| return len(self.brk) > 0
|
|
| def __len__(self):
| return len(self.brk)
|
|
| @property
| def count(self):
| return len(self)
|
|
| @property
| def manualBreakCount(self):
| return len(self)
|
|
| def append(self, brk=None):
| """
| Add a page break
| """
| vals = list(self.brk)
| if not isinstance(brk, Break):
| brk = Break(id=self.count+1)
| vals.append(brk)
| self.brk = vals
|
|
| PageBreak = RowBreak
|
|
| class ColBreak(RowBreak):
|
| tagname = "colBreaks"
|
| count = RowBreak.count
| manualBreakCount = RowBreak.manualBreakCount
| brk = RowBreak.brk
|
| __attrs__ = RowBreak.__attrs__
|
|