2
2
import datetime
3
3
from typing import DefaultDict
4
4
5
- from odf .config import (
6
- ConfigItem ,
7
- ConfigItemMapEntry ,
8
- ConfigItemMapIndexed ,
9
- ConfigItemMapNamed ,
10
- ConfigItemSet ,
11
- )
12
- from odf .opendocument import OpenDocumentSpreadsheet
13
- from odf .style import ParagraphProperties , Style , TableCellProperties , TextProperties
14
- from odf .table import Table , TableCell , TableRow
15
- from odf .text import P
16
-
17
5
import pandas ._libs .json as json
18
6
19
7
from pandas .io .excel ._base import ExcelWriter
@@ -25,6 +13,8 @@ class _ODSWriter(ExcelWriter):
25
13
supported_extensions = (".ods" ,)
26
14
27
15
def __init__ (self , path , engine = None , encoding = None , mode = "w" , ** engine_kwargs ):
16
+ from odf .opendocument import OpenDocumentSpreadsheet
17
+
28
18
engine_kwargs ["engine" ] = engine
29
19
30
20
if mode == "a" :
@@ -46,6 +36,9 @@ def save(self):
46
36
def write_cells (
47
37
self , cells , sheet_name = None , startrow = 0 , startcol = 0 , freeze_panes = None
48
38
):
39
+ from odf .table import Table , TableCell , TableRow
40
+ from odf .text import P
41
+
49
42
# Write the frame cells using odf
50
43
# assert startrow == 0
51
44
# assert startcol == 0
@@ -90,6 +83,8 @@ def _make_table_cell_attributes(self, cell):
90
83
return attributes
91
84
92
85
def _make_table_cell (self , cell ):
86
+ from odf .table import TableCell
87
+
93
88
attributes = self ._make_table_cell_attributes (cell )
94
89
val , fmt = self ._value_with_fmt (cell .val )
95
90
pvalue = value = val
@@ -131,6 +126,13 @@ def _make_table_cell(self, cell):
131
126
)
132
127
133
128
def _process_style (self , style ):
129
+ from odf .style import (
130
+ ParagraphProperties ,
131
+ Style ,
132
+ TableCellProperties ,
133
+ TextProperties ,
134
+ )
135
+
134
136
if style is None :
135
137
return None
136
138
style_key = json .dumps (style )
@@ -164,6 +166,14 @@ def _process_style(self, style):
164
166
return name
165
167
166
168
def _create_freeze_panes (self , sheet_name , freeze_panes ):
169
+ from odf .config import (
170
+ ConfigItem ,
171
+ ConfigItemMapEntry ,
172
+ ConfigItemMapIndexed ,
173
+ ConfigItemMapNamed ,
174
+ ConfigItemSet ,
175
+ )
176
+
167
177
config_item_set = ConfigItemSet (name = "ooo:view-settings" )
168
178
self .book .settings .addElement (config_item_set )
169
179
0 commit comments