11
11
from odf .style import Style , TextProperties , TableCellProperties , ParagraphProperties
12
12
from odf .table import Table , TableRow , TableCell
13
13
from odf .text import P
14
- from odf .config import ConfigItemSet , ConfigItemMapEntry , ConfigItemMapNamed , ConfigItem , ConfigItemMapIndexed
14
+ from odf .config import (
15
+ ConfigItemSet ,
16
+ ConfigItemMapEntry ,
17
+ ConfigItemMapNamed ,
18
+ ConfigItem ,
19
+ ConfigItemMapIndexed ,
20
+ )
15
21
16
22
17
23
class _ODSWriter (ExcelWriter ):
@@ -37,8 +43,9 @@ def save(self):
37
43
self .book .spreadsheet .addElement (sheet )
38
44
return self .book .save (self .path )
39
45
40
- def write_cells (self , cells , sheet_name = None , startrow = 0 , startcol = 0 ,
41
- freeze_panes = None ):
46
+ def write_cells (
47
+ self , cells , sheet_name = None , startrow = 0 , startcol = 0 , freeze_panes = None
48
+ ):
42
49
# Write the frame cells using odf
43
50
# assert startrow == 0
44
51
# assert startcol == 0
@@ -96,22 +103,32 @@ def _make_table_cell(self, cell):
96
103
else :
97
104
value = val .strftime ("%Y-%m-%d" )
98
105
pvalue = val .strftime ("%x" )
99
- return pvalue , TableCell (valuetype = "date" , datevalue = value ,
100
- attributes = attributes )
106
+ return (
107
+ pvalue ,
108
+ TableCell (valuetype = "date" , datevalue = value , attributes = attributes ),
109
+ )
101
110
elif isinstance (val , datetime .date ):
102
111
value = val .strftime ("%Y-%m-%d" )
103
112
pvalue = val .strftime ("%x" )
104
- return pvalue , TableCell (valuetype = "date" , datevalue = value ,
105
- attributes = attributes )
113
+ return (
114
+ pvalue ,
115
+ TableCell (valuetype = "date" , datevalue = value , attributes = attributes ),
116
+ )
106
117
else :
107
118
class_to_cell_type = {
108
119
str : "string" ,
109
120
int : "float" ,
110
121
float : "float" ,
111
122
bool : "boolean" ,
112
123
}
113
- return pvalue , TableCell (valuetype = class_to_cell_type [type (val )],
114
- value = value , attributes = attributes )
124
+ return (
125
+ pvalue ,
126
+ TableCell (
127
+ valuetype = class_to_cell_type [type (val )],
128
+ value = value ,
129
+ attributes = attributes ,
130
+ ),
131
+ )
115
132
116
133
def _process_style (self , style ):
117
134
if style is None :
@@ -129,12 +146,12 @@ def _process_style(self, style):
129
146
if "borders" in style :
130
147
borders = style ["borders" ]
131
148
for side , thickness in borders .items ():
132
- thickness_translation = {
133
- "thin" : "0.75pt solid #000000"
134
- }
149
+ thickness_translation = {"thin" : "0.75pt solid #000000" }
135
150
odf_style .addElement (
136
151
TableCellProperties (
137
- attributes = {f"border{ side } " : thickness_translation [thickness ]}))
152
+ attributes = {f"border{ side } " : thickness_translation [thickness ]}
153
+ )
154
+ )
138
155
if "alignment" in style :
139
156
alignment = style ["alignment" ]
140
157
horizontal = alignment .get ("horizontal" )
@@ -162,21 +179,25 @@ def _create_freeze_panes(self, sheet_name, freeze_panes):
162
179
config_item_map_entry = ConfigItemMapEntry (name = sheet_name )
163
180
config_item_map_named .addElement (config_item_map_entry )
164
181
165
- config_item_map_entry .addElement (ConfigItem (name = "HorizontalSplitMode" ,
166
- type = "short" ,
167
- text = "2" ))
168
- config_item_map_entry .addElement (ConfigItem (name = "VerticalSplitMode" ,
169
- type = "short" ,
170
- text = "2" ))
171
- config_item_map_entry .addElement (ConfigItem (name = "HorizontalSplitPosition" ,
172
- type = "int" ,
173
- text = str (freeze_panes [0 ])))
174
- config_item_map_entry .addElement (ConfigItem (name = "VerticalSplitPosition" ,
175
- type = "int" ,
176
- text = str (freeze_panes [1 ])))
177
- config_item_map_entry .addElement (ConfigItem (name = "PositionRight" ,
178
- type = "int" ,
179
- text = str (freeze_panes [0 ])))
180
- config_item_map_entry .addElement (ConfigItem (name = "PositionBottom" ,
181
- type = "int" ,
182
- text = str (freeze_panes [1 ])))
182
+ config_item_map_entry .addElement (
183
+ ConfigItem (name = "HorizontalSplitMode" , type = "short" , text = "2" )
184
+ )
185
+ config_item_map_entry .addElement (
186
+ ConfigItem (name = "VerticalSplitMode" , type = "short" , text = "2" )
187
+ )
188
+ config_item_map_entry .addElement (
189
+ ConfigItem (
190
+ name = "HorizontalSplitPosition" , type = "int" , text = str (freeze_panes [0 ])
191
+ )
192
+ )
193
+ config_item_map_entry .addElement (
194
+ ConfigItem (
195
+ name = "VerticalSplitPosition" , type = "int" , text = str (freeze_panes [1 ])
196
+ )
197
+ )
198
+ config_item_map_entry .addElement (
199
+ ConfigItem (name = "PositionRight" , type = "int" , text = str (freeze_panes [0 ]))
200
+ )
201
+ config_item_map_entry .addElement (
202
+ ConfigItem (name = "PositionBottom" , type = "int" , text = str (freeze_panes [1 ]))
203
+ )
0 commit comments