@@ -63,7 +63,11 @@ def write_cells(
63
63
col_count = defaultdict (int )
64
64
65
65
for cell in sorted (cells , key = lambda cell : (cell .row , cell .col )):
66
- # print(cell.row, cell.col, cell.val)
66
+ attributes = {}
67
+ print (cell .row , cell .col , cell .val , cell .mergestart , cell .mergeend )
68
+ if cell .mergestart is not None and cell .mergeend is not None :
69
+ attributes = {"numberrowsspanned" : max (1 , cell .mergestart ),
70
+ "numbercolumnsspanned" : cell .mergeend }
67
71
# fill with empty cells if needed
68
72
for _ in range (cell .col - col_count [cell .row ]):
69
73
rows [cell .row ].addElement (TableCell ())
@@ -82,22 +86,22 @@ def write_cells(
82
86
else :
83
87
value = val .strftime ("%Y-%m-%d" )
84
88
pvalue = val .strftime ("%x" )
85
- tc = TableCell (valuetype = "date" , datevalue = value )
89
+ tc = TableCell (valuetype = "date" , datevalue = value , attributes = attributes )
86
90
elif isinstance (val , datetime .date ):
87
91
print ('date' , val .strftime ("%Y-%m-%d" ), val .strftime ("%x" ))
88
92
value = val .strftime ("%Y-%m-%d" )
89
93
pvalue = val .strftime ("%x" )
90
94
# value = val.isoformat()
91
95
# pvalue = val.strftime("%c")
92
- tc = TableCell (valuetype = "date" , datevalue = value )
96
+ tc = TableCell (valuetype = "date" , datevalue = value , attributes = attributes )
93
97
else :
94
98
class_to_cell_type = {
95
99
str : "string" ,
96
100
int : "float" ,
97
101
float : "float" ,
98
102
bool : "boolean" ,
99
103
}
100
- tc = TableCell (valuetype = class_to_cell_type [type (val )], value = value )
104
+ tc = TableCell (valuetype = class_to_cell_type [type (val )], value = value , attributes = attributes )
101
105
rows [cell .row ].addElement (tc )
102
106
col_count [cell .row ] += 1
103
107
p = P (text = pvalue )
@@ -125,8 +129,8 @@ def write_cells(
125
129
else:
126
130
wks.write(startrow + cell.row, startcol + cell.col, val, style)
127
131
"""
128
- for row in rows .values ( ):
129
- wks .addElement (row )
132
+ for row_nr in range ( max ( rows .keys ()) + 1 ):
133
+ wks .addElement (rows [ row_nr ] )
130
134
131
135
@classmethod
132
136
def _style_to_xlwt (
0 commit comments