aspose-cells-foss 25.12.1__py3-none-any.whl → 26.2.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- aspose_cells/__init__.py +88 -0
- aspose_cells/auto_filter.py +527 -0
- aspose_cells/cell.py +483 -0
- aspose_cells/cell_value_handler.py +319 -0
- aspose_cells/cells.py +779 -0
- aspose_cells/cfb_handler.py +445 -0
- aspose_cells/cfb_writer.py +659 -0
- aspose_cells/cfb_writer_minimal.py +337 -0
- aspose_cells/comment_xml.py +475 -0
- aspose_cells/conditional_format.py +1185 -0
- aspose_cells/csv_handler.py +690 -0
- aspose_cells/data_validation.py +911 -0
- aspose_cells/document_properties.py +356 -0
- aspose_cells/encryption_crypto.py +247 -0
- aspose_cells/encryption_params.py +138 -0
- aspose_cells/hyperlink.py +372 -0
- aspose_cells/json_handler.py +185 -0
- aspose_cells/markdown_handler.py +583 -0
- aspose_cells/shared_strings.py +101 -0
- aspose_cells/style.py +841 -0
- aspose_cells/workbook.py +499 -0
- aspose_cells/workbook_hash_password.py +68 -0
- aspose_cells/workbook_properties.py +712 -0
- aspose_cells/worksheet.py +570 -0
- aspose_cells/worksheet_properties.py +1239 -0
- aspose_cells/xlsx_encryptor.py +403 -0
- aspose_cells/xml_autofilter_loader.py +195 -0
- aspose_cells/xml_autofilter_saver.py +173 -0
- aspose_cells/xml_conditional_format_loader.py +215 -0
- aspose_cells/xml_conditional_format_saver.py +351 -0
- aspose_cells/xml_datavalidation_loader.py +239 -0
- aspose_cells/xml_datavalidation_saver.py +245 -0
- aspose_cells/xml_hyperlink_handler.py +323 -0
- aspose_cells/xml_loader.py +986 -0
- aspose_cells/xml_properties_loader.py +512 -0
- aspose_cells/xml_properties_saver.py +607 -0
- aspose_cells/xml_saver.py +1306 -0
- aspose_cells_foss-26.2.2.dist-info/METADATA +190 -0
- aspose_cells_foss-26.2.2.dist-info/RECORD +41 -0
- {aspose_cells_foss-25.12.1.dist-info → aspose_cells_foss-26.2.2.dist-info}/WHEEL +1 -1
- aspose_cells_foss-26.2.2.dist-info/top_level.txt +1 -0
- aspose/__init__.py +0 -14
- aspose/cells/__init__.py +0 -31
- aspose/cells/cell.py +0 -350
- aspose/cells/constants.py +0 -44
- aspose/cells/converters/__init__.py +0 -13
- aspose/cells/converters/csv_converter.py +0 -55
- aspose/cells/converters/json_converter.py +0 -46
- aspose/cells/converters/markdown_converter.py +0 -453
- aspose/cells/drawing/__init__.py +0 -17
- aspose/cells/drawing/anchor.py +0 -172
- aspose/cells/drawing/collection.py +0 -233
- aspose/cells/drawing/image.py +0 -338
- aspose/cells/formats.py +0 -80
- aspose/cells/formula/__init__.py +0 -10
- aspose/cells/formula/evaluator.py +0 -360
- aspose/cells/formula/functions.py +0 -433
- aspose/cells/formula/tokenizer.py +0 -340
- aspose/cells/io/__init__.py +0 -27
- aspose/cells/io/csv/__init__.py +0 -8
- aspose/cells/io/csv/reader.py +0 -88
- aspose/cells/io/csv/writer.py +0 -98
- aspose/cells/io/factory.py +0 -138
- aspose/cells/io/interfaces.py +0 -48
- aspose/cells/io/json/__init__.py +0 -8
- aspose/cells/io/json/reader.py +0 -126
- aspose/cells/io/json/writer.py +0 -119
- aspose/cells/io/md/__init__.py +0 -8
- aspose/cells/io/md/reader.py +0 -161
- aspose/cells/io/md/writer.py +0 -334
- aspose/cells/io/models.py +0 -64
- aspose/cells/io/xlsx/__init__.py +0 -9
- aspose/cells/io/xlsx/constants.py +0 -312
- aspose/cells/io/xlsx/image_writer.py +0 -311
- aspose/cells/io/xlsx/reader.py +0 -284
- aspose/cells/io/xlsx/writer.py +0 -931
- aspose/cells/plugins/__init__.py +0 -6
- aspose/cells/plugins/docling_backend/__init__.py +0 -7
- aspose/cells/plugins/docling_backend/backend.py +0 -535
- aspose/cells/plugins/markitdown_plugin/__init__.py +0 -15
- aspose/cells/plugins/markitdown_plugin/plugin.py +0 -128
- aspose/cells/range.py +0 -210
- aspose/cells/style.py +0 -287
- aspose/cells/utils/__init__.py +0 -54
- aspose/cells/utils/coordinates.py +0 -68
- aspose/cells/utils/exceptions.py +0 -43
- aspose/cells/utils/validation.py +0 -102
- aspose/cells/workbook.py +0 -352
- aspose/cells/worksheet.py +0 -670
- aspose_cells_foss-25.12.1.dist-info/METADATA +0 -189
- aspose_cells_foss-25.12.1.dist-info/RECORD +0 -53
- aspose_cells_foss-25.12.1.dist-info/entry_points.txt +0 -2
- aspose_cells_foss-25.12.1.dist-info/top_level.txt +0 -1
aspose_cells/cell.py
ADDED
|
@@ -0,0 +1,483 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Aspose.Cells for Python - Cell Module
|
|
3
|
+
|
|
4
|
+
This module provides the Cell class which represents a single cell in a worksheet.
|
|
5
|
+
The Cell class provides methods and properties for accessing and modifying cell values,
|
|
6
|
+
formulas, styles, and comments.
|
|
7
|
+
|
|
8
|
+
Compatible with Aspose.Cells for .NET API structure.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
import sys
|
|
12
|
+
from datetime import datetime, date, time
|
|
13
|
+
from .style import Style
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class Cell:
|
|
17
|
+
"""
|
|
18
|
+
Represents a single cell in a worksheet.
|
|
19
|
+
|
|
20
|
+
The Cell class provides properties and methods for working with individual cells,
|
|
21
|
+
including value access, formula handling, style application, and comment management.
|
|
22
|
+
|
|
23
|
+
Examples:
|
|
24
|
+
>>> from aspose_cells import Workbook
|
|
25
|
+
>>> wb = Workbook()
|
|
26
|
+
>>> ws = wb.worksheets[0]
|
|
27
|
+
>>> cell = ws.cells['A1']
|
|
28
|
+
>>> cell.value = "Hello"
|
|
29
|
+
>>> cell.style.font.bold = True
|
|
30
|
+
>>> cell.set_comment("This is a note", "Author")
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
def __init__(self, value=None, formula=None):
|
|
34
|
+
"""
|
|
35
|
+
Initializes a new instance of the Cell class.
|
|
36
|
+
|
|
37
|
+
Args:
|
|
38
|
+
value: The value to store in the cell. Can be None, int, float, str, bool,
|
|
39
|
+
datetime, date, or time objects.
|
|
40
|
+
formula (str, optional): The formula to store in the cell.
|
|
41
|
+
|
|
42
|
+
Examples:
|
|
43
|
+
>>> cell = Cell()
|
|
44
|
+
>>> cell = Cell("Hello")
|
|
45
|
+
>>> cell = Cell(42, "=SUM(A1:B1)")
|
|
46
|
+
"""
|
|
47
|
+
self._value = value
|
|
48
|
+
self._formula = formula
|
|
49
|
+
self._style = Style()
|
|
50
|
+
self._comment = None
|
|
51
|
+
self._style_index = 0 # Internal use for saving
|
|
52
|
+
|
|
53
|
+
# Debug logging
|
|
54
|
+
if '--debug' in sys.argv:
|
|
55
|
+
print(f"DEBUG Cell.__init__: Created new cell with value={value}, formula={formula}")
|
|
56
|
+
print(f" Initial borders: top={self._style.borders.top.line_style}, {self._style.borders.top.color}")
|
|
57
|
+
|
|
58
|
+
# Properties
|
|
59
|
+
|
|
60
|
+
@property
|
|
61
|
+
def value(self):
|
|
62
|
+
"""
|
|
63
|
+
Gets or sets the value of the cell.
|
|
64
|
+
|
|
65
|
+
Returns:
|
|
66
|
+
The cell value. Can be None, int, float, str, bool, datetime, date, or time.
|
|
67
|
+
|
|
68
|
+
Examples:
|
|
69
|
+
>>> cell.value = "Hello"
|
|
70
|
+
>>> print(cell.value)
|
|
71
|
+
"""
|
|
72
|
+
return self._value
|
|
73
|
+
|
|
74
|
+
@value.setter
|
|
75
|
+
def value(self, val):
|
|
76
|
+
"""
|
|
77
|
+
Sets the value of the cell.
|
|
78
|
+
|
|
79
|
+
Args:
|
|
80
|
+
val: The value to set. Can be None, int, float, str, bool, datetime, date, or time.
|
|
81
|
+
"""
|
|
82
|
+
self._value = val
|
|
83
|
+
|
|
84
|
+
@property
|
|
85
|
+
def formula(self):
|
|
86
|
+
"""
|
|
87
|
+
Gets or sets the formula of the cell.
|
|
88
|
+
|
|
89
|
+
Returns:
|
|
90
|
+
str or None: The formula string, or None if no formula is set.
|
|
91
|
+
|
|
92
|
+
Examples:
|
|
93
|
+
>>> cell.formula = "=SUM(A1:B1)"
|
|
94
|
+
>>> print(cell.formula)
|
|
95
|
+
"""
|
|
96
|
+
return self._formula
|
|
97
|
+
|
|
98
|
+
@formula.setter
|
|
99
|
+
def formula(self, val):
|
|
100
|
+
"""
|
|
101
|
+
Sets the formula of the cell.
|
|
102
|
+
|
|
103
|
+
Args:
|
|
104
|
+
val (str): The formula string to set.
|
|
105
|
+
"""
|
|
106
|
+
self._formula = val
|
|
107
|
+
|
|
108
|
+
@property
|
|
109
|
+
def style(self):
|
|
110
|
+
"""
|
|
111
|
+
Gets or sets the style of the cell.
|
|
112
|
+
|
|
113
|
+
Returns:
|
|
114
|
+
Style: The Style object containing cell formatting properties.
|
|
115
|
+
|
|
116
|
+
Examples:
|
|
117
|
+
>>> cell.style.font.bold = True
|
|
118
|
+
>>> cell.style.set_fill_color('FFFF0000')
|
|
119
|
+
"""
|
|
120
|
+
return self._style
|
|
121
|
+
|
|
122
|
+
@style.setter
|
|
123
|
+
def style(self, value):
|
|
124
|
+
"""
|
|
125
|
+
Sets the style of the cell.
|
|
126
|
+
|
|
127
|
+
Args:
|
|
128
|
+
value (Style): The Style object to apply to the cell.
|
|
129
|
+
"""
|
|
130
|
+
if '--debug' in sys.argv:
|
|
131
|
+
print(f"DEBUG Cell.__setattr__: Setting style to {value}")
|
|
132
|
+
if hasattr(value, 'borders'):
|
|
133
|
+
print(f" New style borders: top={value.borders.top.line_style}, {value.borders.top.color}")
|
|
134
|
+
object.__setattr__(self, '_style', value)
|
|
135
|
+
|
|
136
|
+
@property
|
|
137
|
+
def comment(self):
|
|
138
|
+
"""
|
|
139
|
+
Gets the comment associated with the cell.
|
|
140
|
+
|
|
141
|
+
Returns:
|
|
142
|
+
dict or None: Dictionary containing 'text' and 'author' keys, or None if no comment.
|
|
143
|
+
|
|
144
|
+
Examples:
|
|
145
|
+
>>> if cell.comment:
|
|
146
|
+
... print(cell.comment['text'])
|
|
147
|
+
"""
|
|
148
|
+
return self._comment
|
|
149
|
+
|
|
150
|
+
# Data type detection
|
|
151
|
+
|
|
152
|
+
@property
|
|
153
|
+
def data_type(self):
|
|
154
|
+
"""
|
|
155
|
+
Gets the data type of the cell value.
|
|
156
|
+
|
|
157
|
+
Returns:
|
|
158
|
+
str: The data type of the cell value. Possible values:
|
|
159
|
+
- 'none': Cell is empty (value is None)
|
|
160
|
+
- 'boolean': Boolean value (True/False or string "TRUE"/"FALSE")
|
|
161
|
+
- 'numeric': Integer or floating-point number
|
|
162
|
+
- 'datetime': datetime, date, or time object
|
|
163
|
+
- 'string': Text string
|
|
164
|
+
- 'unknown': Any other type
|
|
165
|
+
|
|
166
|
+
Examples:
|
|
167
|
+
>>> cell.value = "Hello"
|
|
168
|
+
>>> print(cell.data_type) # 'string'
|
|
169
|
+
>>> cell.value = 42
|
|
170
|
+
>>> print(cell.data_type) # 'numeric'
|
|
171
|
+
"""
|
|
172
|
+
if self._value is None:
|
|
173
|
+
return 'none'
|
|
174
|
+
elif isinstance(self._value, bool):
|
|
175
|
+
return 'boolean'
|
|
176
|
+
elif isinstance(self._value, (int, float)):
|
|
177
|
+
return 'numeric'
|
|
178
|
+
elif isinstance(self._value, (datetime, date, time)):
|
|
179
|
+
return 'datetime'
|
|
180
|
+
elif isinstance(self._value, str):
|
|
181
|
+
# Check for boolean strings
|
|
182
|
+
if self._value.upper() in ('TRUE', 'FALSE'):
|
|
183
|
+
return 'boolean'
|
|
184
|
+
return 'string'
|
|
185
|
+
else:
|
|
186
|
+
return 'unknown'
|
|
187
|
+
|
|
188
|
+
# Cell value methods
|
|
189
|
+
|
|
190
|
+
def is_empty(self):
|
|
191
|
+
"""
|
|
192
|
+
Checks if the cell is empty.
|
|
193
|
+
|
|
194
|
+
Returns:
|
|
195
|
+
bool: True if the cell value is None, False otherwise.
|
|
196
|
+
|
|
197
|
+
Examples:
|
|
198
|
+
>>> if cell.is_empty():
|
|
199
|
+
... print("Cell is empty")
|
|
200
|
+
"""
|
|
201
|
+
return self._value is None
|
|
202
|
+
|
|
203
|
+
def clear_value(self):
|
|
204
|
+
"""
|
|
205
|
+
Clears the value of the cell (sets it to None).
|
|
206
|
+
|
|
207
|
+
Examples:
|
|
208
|
+
>>> cell.clear_value()
|
|
209
|
+
"""
|
|
210
|
+
self._value = None
|
|
211
|
+
|
|
212
|
+
def clear_formula(self):
|
|
213
|
+
"""
|
|
214
|
+
Clears the formula of the cell (sets it to None).
|
|
215
|
+
|
|
216
|
+
Examples:
|
|
217
|
+
>>> cell.clear_formula()
|
|
218
|
+
"""
|
|
219
|
+
self._formula = None
|
|
220
|
+
|
|
221
|
+
def clear(self):
|
|
222
|
+
"""
|
|
223
|
+
Clears both the value and formula of the cell.
|
|
224
|
+
|
|
225
|
+
Examples:
|
|
226
|
+
>>> cell.clear()
|
|
227
|
+
"""
|
|
228
|
+
self._value = None
|
|
229
|
+
self._formula = None
|
|
230
|
+
|
|
231
|
+
# Comment methods
|
|
232
|
+
|
|
233
|
+
def set_comment(self, text, author='None', width=None, height=None):
|
|
234
|
+
"""
|
|
235
|
+
Sets a comment on the cell.
|
|
236
|
+
|
|
237
|
+
Args:
|
|
238
|
+
text (str): The comment text.
|
|
239
|
+
author (str, optional): The author of the comment. Defaults to 'None'.
|
|
240
|
+
width (float, optional): The width of the comment box in points. Defaults to None (uses Excel default).
|
|
241
|
+
height (float, optional): The height of the comment box in points. Defaults to None (uses Excel default).
|
|
242
|
+
|
|
243
|
+
Examples:
|
|
244
|
+
>>> cell.set_comment("This is important", "John")
|
|
245
|
+
>>> cell.set_comment("Note") # Author defaults to 'None'
|
|
246
|
+
>>> cell.set_comment("Large note", "John", width=200, height=100)
|
|
247
|
+
"""
|
|
248
|
+
# If author is empty string, set it to "None"
|
|
249
|
+
if author == '':
|
|
250
|
+
author = 'None'
|
|
251
|
+
self._comment = {
|
|
252
|
+
'text': text,
|
|
253
|
+
'author': author,
|
|
254
|
+
'width': width,
|
|
255
|
+
'height': height
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
def get_comment(self):
|
|
259
|
+
"""
|
|
260
|
+
Gets the comment from the cell.
|
|
261
|
+
|
|
262
|
+
Returns:
|
|
263
|
+
dict or None: Dictionary containing 'text' and 'author' keys, or None if no comment.
|
|
264
|
+
|
|
265
|
+
Examples:
|
|
266
|
+
>>> comment = cell.get_comment()
|
|
267
|
+
>>> if comment:
|
|
268
|
+
... print(f"{comment['author']}: {comment['text']}")
|
|
269
|
+
"""
|
|
270
|
+
return self._comment
|
|
271
|
+
|
|
272
|
+
def clear_comment(self):
|
|
273
|
+
"""
|
|
274
|
+
Clears the comment from the cell.
|
|
275
|
+
|
|
276
|
+
Examples:
|
|
277
|
+
>>> cell.clear_comment()
|
|
278
|
+
"""
|
|
279
|
+
self._comment = None
|
|
280
|
+
|
|
281
|
+
def has_comment(self):
|
|
282
|
+
"""
|
|
283
|
+
Checks if the cell has a comment.
|
|
284
|
+
|
|
285
|
+
Returns:
|
|
286
|
+
bool: True if the cell has a comment, False otherwise.
|
|
287
|
+
|
|
288
|
+
Examples:
|
|
289
|
+
>>> if cell.has_comment():
|
|
290
|
+
... print("Cell has a comment")
|
|
291
|
+
"""
|
|
292
|
+
return self._comment is not None
|
|
293
|
+
|
|
294
|
+
def set_comment_size(self, width, height):
|
|
295
|
+
"""
|
|
296
|
+
Sets the size of the comment box.
|
|
297
|
+
|
|
298
|
+
Args:
|
|
299
|
+
width (float): The width of the comment box in points.
|
|
300
|
+
height (float): The height of the comment box in points.
|
|
301
|
+
|
|
302
|
+
Examples:
|
|
303
|
+
>>> cell.set_comment("Note", "John")
|
|
304
|
+
>>> cell.set_comment_size(150, 80)
|
|
305
|
+
"""
|
|
306
|
+
if self._comment is None:
|
|
307
|
+
raise ValueError("Cell has no comment. Call set_comment() first.")
|
|
308
|
+
self._comment['width'] = width
|
|
309
|
+
self._comment['height'] = height
|
|
310
|
+
|
|
311
|
+
def get_comment_size(self):
|
|
312
|
+
"""
|
|
313
|
+
Gets the size of the comment box.
|
|
314
|
+
|
|
315
|
+
Returns:
|
|
316
|
+
tuple or None: A tuple of (width, height) in points, or None if no size is set.
|
|
317
|
+
|
|
318
|
+
Examples:
|
|
319
|
+
>>> size = cell.get_comment_size()
|
|
320
|
+
>>> if size:
|
|
321
|
+
... print(f"Width: {size[0]}, Height: {size[1]}")
|
|
322
|
+
"""
|
|
323
|
+
if self._comment is None:
|
|
324
|
+
return None
|
|
325
|
+
width = self._comment.get('width')
|
|
326
|
+
height = self._comment.get('height')
|
|
327
|
+
if width is not None and height is not None:
|
|
328
|
+
return (width, height)
|
|
329
|
+
return None
|
|
330
|
+
|
|
331
|
+
# Style methods
|
|
332
|
+
|
|
333
|
+
def apply_style(self, style):
|
|
334
|
+
"""
|
|
335
|
+
Applies a style to the cell.
|
|
336
|
+
|
|
337
|
+
Args:
|
|
338
|
+
style (Style): The Style object to apply to the cell.
|
|
339
|
+
|
|
340
|
+
Examples:
|
|
341
|
+
>>> from aspose_cells import Style
|
|
342
|
+
>>> style = Style()
|
|
343
|
+
>>> style.font.bold = True
|
|
344
|
+
>>> cell.apply_style(style)
|
|
345
|
+
"""
|
|
346
|
+
self._style = style
|
|
347
|
+
|
|
348
|
+
def get_style(self):
|
|
349
|
+
"""
|
|
350
|
+
Gets the style of the cell.
|
|
351
|
+
|
|
352
|
+
Returns:
|
|
353
|
+
Style: The Style object containing cell formatting properties.
|
|
354
|
+
|
|
355
|
+
Examples:
|
|
356
|
+
>>> style = cell.get_style()
|
|
357
|
+
>>> print(style.font.name)
|
|
358
|
+
"""
|
|
359
|
+
return self._style
|
|
360
|
+
|
|
361
|
+
def clear_style(self):
|
|
362
|
+
"""
|
|
363
|
+
Clears the style of the cell (resets to default).
|
|
364
|
+
|
|
365
|
+
Examples:
|
|
366
|
+
>>> cell.clear_style()
|
|
367
|
+
"""
|
|
368
|
+
self._style = Style()
|
|
369
|
+
|
|
370
|
+
# Formula methods
|
|
371
|
+
|
|
372
|
+
def has_formula(self):
|
|
373
|
+
"""
|
|
374
|
+
Checks if the cell has a formula.
|
|
375
|
+
|
|
376
|
+
Returns:
|
|
377
|
+
bool: True if the cell has a formula, False otherwise.
|
|
378
|
+
|
|
379
|
+
Examples:
|
|
380
|
+
>>> if cell.has_formula():
|
|
381
|
+
... print("Cell contains a formula")
|
|
382
|
+
"""
|
|
383
|
+
return self._formula is not None
|
|
384
|
+
|
|
385
|
+
def is_numeric_value(self):
|
|
386
|
+
"""
|
|
387
|
+
Checks if the cell value is numeric.
|
|
388
|
+
|
|
389
|
+
Returns:
|
|
390
|
+
bool: True if the cell value is an int or float, False otherwise.
|
|
391
|
+
|
|
392
|
+
Examples:
|
|
393
|
+
>>> if cell.is_numeric_value():
|
|
394
|
+
... print("Cell contains a number")
|
|
395
|
+
"""
|
|
396
|
+
return isinstance(self._value, (int, float))
|
|
397
|
+
|
|
398
|
+
def is_text_value(self):
|
|
399
|
+
"""
|
|
400
|
+
Checks if the cell value is text.
|
|
401
|
+
|
|
402
|
+
Returns:
|
|
403
|
+
bool: True if the cell value is a string, False otherwise.
|
|
404
|
+
|
|
405
|
+
Examples:
|
|
406
|
+
>>> if cell.is_text_value():
|
|
407
|
+
... print("Cell contains text")
|
|
408
|
+
"""
|
|
409
|
+
return isinstance(self._value, str)
|
|
410
|
+
|
|
411
|
+
def is_boolean_value(self):
|
|
412
|
+
"""
|
|
413
|
+
Checks if the cell value is boolean.
|
|
414
|
+
|
|
415
|
+
Returns:
|
|
416
|
+
bool: True if the cell value is a bool or boolean string ("TRUE"/"FALSE"), False otherwise.
|
|
417
|
+
|
|
418
|
+
Examples:
|
|
419
|
+
>>> if cell.is_boolean_value():
|
|
420
|
+
... print("Cell contains a boolean value")
|
|
421
|
+
"""
|
|
422
|
+
return self.data_type == 'boolean'
|
|
423
|
+
|
|
424
|
+
def is_date_time_value(self):
|
|
425
|
+
"""
|
|
426
|
+
Checks if the cell value is a date/time.
|
|
427
|
+
|
|
428
|
+
Returns:
|
|
429
|
+
bool: True if the cell value is a datetime, date, or time object, False otherwise.
|
|
430
|
+
|
|
431
|
+
Examples:
|
|
432
|
+
>>> if cell.is_date_time_value():
|
|
433
|
+
... print("Cell contains a date/time value")
|
|
434
|
+
"""
|
|
435
|
+
return self.data_type == 'datetime'
|
|
436
|
+
|
|
437
|
+
# String representation
|
|
438
|
+
|
|
439
|
+
def __str__(self):
|
|
440
|
+
"""
|
|
441
|
+
Returns a string representation of the cell value.
|
|
442
|
+
|
|
443
|
+
Returns:
|
|
444
|
+
str: String representation of the cell value, or empty string if value is None.
|
|
445
|
+
"""
|
|
446
|
+
return str(self._value) if self._value is not None else ''
|
|
447
|
+
|
|
448
|
+
def __repr__(self):
|
|
449
|
+
"""
|
|
450
|
+
Returns a detailed string representation of the cell.
|
|
451
|
+
|
|
452
|
+
Returns:
|
|
453
|
+
str: Detailed representation including value, formula, and data type.
|
|
454
|
+
"""
|
|
455
|
+
return f"Cell(value={self._value!r}, formula={self._formula!r}, type={self.data_type})"
|
|
456
|
+
|
|
457
|
+
# Comparison methods
|
|
458
|
+
|
|
459
|
+
def __eq__(self, other):
|
|
460
|
+
"""
|
|
461
|
+
Checks if two cells are equal based on their values.
|
|
462
|
+
|
|
463
|
+
Args:
|
|
464
|
+
other: Another Cell object or value to compare with.
|
|
465
|
+
|
|
466
|
+
Returns:
|
|
467
|
+
bool: True if values are equal, False otherwise.
|
|
468
|
+
"""
|
|
469
|
+
if isinstance(other, Cell):
|
|
470
|
+
return self._value == other._value
|
|
471
|
+
return self._value == other
|
|
472
|
+
|
|
473
|
+
def __ne__(self, other):
|
|
474
|
+
"""
|
|
475
|
+
Checks if two cells are not equal based on their values.
|
|
476
|
+
|
|
477
|
+
Args:
|
|
478
|
+
other: Another Cell object or value to compare with.
|
|
479
|
+
|
|
480
|
+
Returns:
|
|
481
|
+
bool: True if values are not equal, False otherwise.
|
|
482
|
+
"""
|
|
483
|
+
return not self.__eq__(other)
|