Cell class
Cell class
Encapsulates the object that represents a single Workbook cell.
The Cell type exposes the following members:
Properties
Property | Description |
---|---|
worksheet | Gets the parent worksheet. |
date_time_value | Gets the DateTime value contained in the cell. |
row | Gets row number (zero based) of the cell. |
column | Gets column number (zero based) of the cell. |
is_formula | Represents if the specified cell contains formula. |
type | Represents cell value type. |
name | Gets the name of the cell. |
is_error_value | Checks if the value of this cell is an error. |
is_numeric_value | Indicates whether the value of this cell is numeric(int, double and datetime) |
string_value | Gets the string value contained in the cell. If the type of this cell is string, then return the string value itself. For other cell types, the formatted string value (formatted with the specified style of this cell) will be returned. The formatted cell value is same with what you can get from excel when copying a cell as text(such as copying cell to text editor or exporting to csv). |
string_value_without_format | Gets cell’s value as string without any format. |
number_category_type | Represents the category type of this cell’s number formatting. |
display_string_value | Gets the formatted string value of this cell by cell’s display style. |
int_value | Gets the integer value contained in the cell. |
double_value | Gets the double value contained in the cell. |
float_value | Gets the float value contained in the cell. |
bool_value | Gets the boolean value contained in the cell. |
has_custom_style | Indicates whether this cell has custom style settings(different from the default one inherited from corresponding row, column, or workbook). |
shared_style_index | Gets cell’s shared style index in the style pool. |
formula | Gets or sets a formula of the Cell . |
formula_local | Get the locale formatted formula of the cell. |
r1c1_formula | Gets or sets a R1C1 formula of the Cell . |
contains_external_link | Indicates whether this cell contains an external link. Only applies when the cell is a formula cell. |
is_array_header | Indicates the cell’s formula is an array formula and it is the first cell of the array. |
is_dynamic_array_formula | Indicates whether the cell’s formula is dynamic array formula(true) or legacy array formula(false). |
is_array_formula | Indicates whether the cell formula is an array formula. |
is_in_array | Indicates whether the cell formula is an array formula. |
is_shared_formula | Indicates whether the cell formula is part of shared formula. |
is_table_formula | Indicates whether this cell is part of table formula. |
is_in_table | Indicates whether this cell is part of table formula. |
value | Gets/sets the value contained in this cell. |
is_style_set | Indicates if the cell’s style is set. If return false, it means this cell has a default cell format. |
is_merged | Checks if a cell is part of a merged range or not. |
comment | Gets the comment of this cell. |
html_string | Gets and sets the html string which contains data and some formats in this cell. |
is_check_box_style | Indicates whether setting this cell as a check box. |
embedded_image | Gets and sets the embeddedn image in the cell. |
Methods
Method | Description |
---|---|
put_value | Puts a boolean value into the cell. |
put_value | Puts an integer value into the cell. |
put_value | Puts a double value into the cell. |
put_value | Puts a value into the cell, if appropriate the value will be converted to other data type and cell’s number format will be reset. |
put_value | Puts a string value into the cell and converts the value to other data type if appropriate. |
put_value | Puts a string value into the cell. |
put_value | Puts a DateTime value into the cell. |
put_value | Puts an object value into the cell. |
get_display_style | Gets the display style of the cell. If this cell is also affected by other settings such as conditional formatting, list objects, etc., then the display style may be different from cell.GetStyle(). |
get_display_style | Gets the display style of the cell. If the cell is conditional formatted, the display style is not same as the cell.GetStyle(). |
get_style | Gets the cell style. |
get_style | If checkBorders is true, check whether other cells’ borders will effect the style of this cell. |
set_style | Sets the cell style. |
set_style | Apply the changed property of style to the cell. |
set_style | Apply the cell style based on flags. |
set_formula | Set the formula and the value(calculated result) of the formula. |
set_formula | Set the formula and the value(calculated result) of the formula. |
set_formula | Set the formula and the value of the formula. |
set_formula | Set the formula and the value(calculated result) of the formula. |
set_array_formula | Sets an array formula to a range of cells. |
set_array_formula | Sets an array formula(legacy array formula entered via CTRL+SHIFT+ENTER in ms excel) to a range of cells. |
set_array_formula | Sets an array formula to a range of cells. |
set_array_formula | Sets an array formula to a range of cells. |
set_shared_formula | Sets a formula to a range of cells. |
set_shared_formula | Sets shared formulas to a range of cells. |
set_shared_formula | Sets shared formulas to a range of cells. |
set_shared_formula | Sets shared formulas to a range of cells. |
get_leafs | Get all cells which reference to this cell directly and need to be updated when this cell is modified. |
get_leafs | Get all cells which will be updated when this cell is modified. |
set_dynamic_array_formula | Sets dynamic array formula and make the formula spill into neighboring cells if possible. |
set_dynamic_array_formula | Sets dynamic array formula and make the formula spill into neighboring cells if possible. |
set_dynamic_array_formula | Sets dynamic array formula and make the formula spill into neighboring cells if possible. |
set_table_formula | Create two-variable data table for given range starting from this cell. |
set_table_formula | Create one-variable data table for given range starting from this cell. |
set_table_formula | Create two-variable data table for given range starting from this cell. |
set_table_formula | Create one-variable data table for given range starting from this cell. |
get_characters | Returns all Characters objects that represents a range of characters within the cell text. |
get_characters | Returns all Characters objects that represents a range of characters within the cell text. |
calculate | Calculates the formula of the cell. |
get_string_value | Gets the string value by specific formatted strategy. |
get_width_of_value | Gets the width of the value in unit of pixels. |
get_height_of_value | Gets the height of the value in unit of pixels. |
get_format_conditions | Gets format conditions which applies to this cell. |
get_formula | Get the formula of this cell. |
get_precedents | Gets all references appearing in this cell’s formula. |
get_dependents | Get all cells whose formula references to this cell directly. |
get_precedents_in_calculation | Gets all precedents(reference to cells in current workbook) used by this cell’s formula while calculating it. |
get_dependents_in_calculation | Gets all cells whose calculated result depends on this cell. |
get_array_range | Gets the array range if the cell’s formula is an array formula. |
remove_array_formula | Remove array formula. |
copy | Copies data from a source cell. |
characters | Returns a Characters object that represents a range of characters within the cell text. |
replace | Replace text of the cell with options. |
insert_text | Insert some characters to the cell. If the cell is rich formatted, this method could keep the original formatting. |
is_rich_text | Indicates whether the string value of this cell is a rich formatted text. |
set_characters | Sets rich text format of the cell. |
get_merged_range | Returns a Range object which represents a merged range. |
get_html_string | Gets the html string which contains data and some formats in this cell. |
to_json | Convert Cell to JSON struct data. |
equals | Checks whether this object refers to the same cell with another cell object. |
get_conditional_formatting_result | Get the result of the conditional formatting. |
get_validation | Gets the validation applied to this cell. |
get_validation_value | Gets the value of validation which applied to this cell. |
get_table | Gets the table which contains this cell. |
get_rich_value | Gets rich value of the cell. |
Example
from aspose.cells import TextAlignmentType, Workbook
from aspose.pydrawing import Color
excel = Workbook()
cells = excel.worksheets[0].cells
# Put a string into a cell
cell = cells.get(0, 0)
cell.put_value("Hello")
first = cell.string_value
# Put an integer into a cell
cell = cells.get("B1")
cell.put_value(12)
second = cell.int_value
# Put a double into a cell
cell = cells.get(0, 2)
cell.put_value(-1.234)
third = cell.double_value
# Put a formula into a cell
cell = cells.get("D1")
cell.formula = "=B1 + C1"
# Put a combined formula: "sum(average(b1,c1), b1)" to cell at b2
cell = cells.get("b2")
cell.formula = "=sum(average(b1,c1), b1)"
# Set style of a cell
style = cell.get_style()
# Set background color
style.background_color = Color.yellow
# Set format of a cell
style.font.name = "Courier New"
style.vertical_alignment = TextAlignmentType.TOP
cell.set_style(style)
See Also
- module
aspose.cells
- class
Cell
- class
Range