@@ -171,7 +171,7 @@ def _get_cell_value(self, cell, convert_float: bool) -> Scalar:
171
171
cell_value = cell .attributes .get ((OFFICENS , "value" ))
172
172
return float (cell_value )
173
173
elif cell_type == "string" :
174
- return str (cell )
174
+ return self . _get_cell_string_value (cell )
175
175
elif cell_type == "currency" :
176
176
cell_value = cell .attributes .get ((OFFICENS , "value" ))
177
177
return float (cell_value )
@@ -182,3 +182,24 @@ def _get_cell_value(self, cell, convert_float: bool) -> Scalar:
182
182
return pd .to_datetime (str (cell )).time ()
183
183
else :
184
184
raise ValueError (f"Unrecognized type { cell_type } " )
185
+
186
+ def _get_cell_string_value (self , cell ):
187
+ from odf .element import Text , Element
188
+ from odf .text import S , P
189
+ from odf .namespaces import TEXTNS
190
+
191
+ text_p = P ().qname
192
+ text_s = S ().qname
193
+
194
+ p = cell .childNodes [0 ]
195
+
196
+ value = []
197
+ if p .qname == text_p :
198
+ for k , fragment in enumerate (p .childNodes ):
199
+ if isinstance (fragment , Text ):
200
+ value .append (fragment .data )
201
+ elif isinstance (fragment , Element ):
202
+ if fragment .qname == text_s :
203
+ spaces = int (fragment .attributes .get ((TEXTNS , 'c' ), 1 ))
204
+ value .append (' ' * spaces )
205
+ return '' .join (value )
0 commit comments