@@ -36,12 +36,12 @@ def save(self):
36
36
def write_cells (
37
37
self , cells , sheet_name = None , startrow = 0 , startcol = 0 , freeze_panes = None
38
38
):
39
+ """
40
+ Write the frame cells using odf
41
+ """
39
42
from odf .table import Table , TableCell , TableRow
40
43
from odf .text import P
41
44
42
- # Write the frame cells using odf
43
- # assert startrow == 0
44
- # assert startcol == 0
45
45
sheet_name = self ._get_sheet_name (sheet_name )
46
46
47
47
if sheet_name in self .sheets :
@@ -53,10 +53,18 @@ def write_cells(
53
53
if _validate_freeze_panes (freeze_panes ):
54
54
self ._create_freeze_panes (sheet_name , freeze_panes )
55
55
56
+ for _ in range (startrow ):
57
+ wks .addElement (TableRow ())
58
+
56
59
rows : DefaultDict = defaultdict (TableRow )
57
60
col_count : DefaultDict = defaultdict (int )
58
61
59
62
for cell in sorted (cells , key = lambda cell : (cell .row , cell .col )):
63
+ # only add empty cells if the row is still empty
64
+ if not col_count [cell .row ]:
65
+ for _ in range (startcol ):
66
+ rows [cell .row ].addElement (TableCell ())
67
+
60
68
# fill with empty cells if needed
61
69
for _ in range (cell .col - col_count [cell .row ]):
62
70
rows [cell .row ].addElement (TableCell ())
0 commit comments