4
4
# import pandas._libs.json as json
5
5
6
6
from pandas .io .excel ._base import ExcelWriter
7
+
7
8
# from pandas.io.excel._util import _validate_freeze_panes
8
9
9
10
from odf .opendocument import OpenDocumentSpreadsheet
@@ -49,7 +50,6 @@ def write_cells(
49
50
wks = self .sheets [sheet_name ]
50
51
else :
51
52
wks = Table (name = sheet_name )
52
- # wks = self.book.add_sheet(sheet_name) (do at the end or immediately? FIXME)
53
53
self .sheets [sheet_name ] = wks
54
54
55
55
# if _validate_freeze_panes(freeze_panes):
@@ -66,8 +66,10 @@ def write_cells(
66
66
attributes = {}
67
67
print (cell .row , cell .col , cell .val , cell .mergestart , cell .mergeend )
68
68
if cell .mergestart is not None and cell .mergeend is not None :
69
- attributes = {"numberrowsspanned" : max (1 , cell .mergestart ),
70
- "numbercolumnsspanned" : cell .mergeend }
69
+ attributes = {
70
+ "numberrowsspanned" : max (1 , cell .mergestart ),
71
+ "numbercolumnsspanned" : cell .mergeend ,
72
+ }
71
73
# fill with empty cells if needed
72
74
for _ in range (cell .col - col_count [cell .row ]):
73
75
rows [cell .row ].addElement (TableCell ())
@@ -79,7 +81,6 @@ def write_cells(
79
81
value = str (val ).lower ()
80
82
pvalue = str (val ).upper ()
81
83
if isinstance (val , datetime .datetime ):
82
- print ('datetime' , val .strftime ("%Y-%m-%d" ), val .strftime ("%x" ))
83
84
if val .time ():
84
85
value = val .isoformat ()
85
86
pvalue = val .strftime ("%c" )
@@ -88,11 +89,8 @@ def write_cells(
88
89
pvalue = val .strftime ("%x" )
89
90
tc = TableCell (valuetype = "date" , datevalue = value , attributes = attributes )
90
91
elif isinstance (val , datetime .date ):
91
- print ('date' , val .strftime ("%Y-%m-%d" ), val .strftime ("%x" ))
92
92
value = val .strftime ("%Y-%m-%d" )
93
93
pvalue = val .strftime ("%x" )
94
- # value = val.isoformat()
95
- # pvalue = val.strftime("%c")
96
94
tc = TableCell (valuetype = "date" , datevalue = value , attributes = attributes )
97
95
else :
98
96
class_to_cell_type = {
@@ -101,7 +99,11 @@ def write_cells(
101
99
float : "float" ,
102
100
bool : "boolean" ,
103
101
}
104
- tc = TableCell (valuetype = class_to_cell_type [type (val )], value = value , attributes = attributes )
102
+ tc = TableCell (
103
+ valuetype = class_to_cell_type [type (val )],
104
+ value = value ,
105
+ attributes = attributes ,
106
+ )
105
107
rows [cell .row ].addElement (tc )
106
108
col_count [cell .row ] += 1
107
109
p = P (text = pvalue )
@@ -116,18 +118,6 @@ def write_cells(
116
118
else:
117
119
style = self._convert_to_style(cell.style, fmt)
118
120
style_dict[stylekey] = style
119
-
120
- if cell.mergestart is not None and cell.mergeend is not None:
121
- wks.write_merge(
122
- startrow + cell.row,
123
- startrow + cell.mergestart,
124
- startcol + cell.col,
125
- startcol + cell.mergeend,
126
- val,
127
- style,
128
- )
129
- else:
130
- wks.write(startrow + cell.row, startcol + cell.col, val, style)
131
121
"""
132
122
for row_nr in range (max (rows .keys ()) + 1 ):
133
123
wks .addElement (rows [row_nr ])
0 commit comments