152 lines
2.1 KiB
ReStructuredText
152 lines
2.1 KiB
ReStructuredText
Cells and Ranges
|
|
----------------
|
|
|
|
By selection
|
|
^^^^^^^^^^^^
|
|
|
|
.. code-block:: python
|
|
|
|
doc = app.active
|
|
selection = doc.selection
|
|
app.debug(selection)
|
|
|
|
|
|
By name
|
|
^^^^^^^
|
|
|
|
.. code-block:: python
|
|
|
|
doc = app.active
|
|
sheet = doc.active
|
|
cell = sheet['A1']
|
|
rango = sheet['C10:D15']
|
|
|
|
app.debug(cell)
|
|
app.debug(rango)
|
|
|
|
|
|
By position
|
|
^^^^^^^^^^^
|
|
|
|
For cells: `sheet[row,column]`
|
|
|
|
For ranges: `sheet[start_row:end_row, start_column:end_column]`
|
|
|
|
.. code-block:: python
|
|
|
|
sheet = app.active.active
|
|
|
|
'Cell A10
|
|
cell = sheet[9,0]
|
|
|
|
'Range A1:C10
|
|
rango = sheet[0:10,0:3]
|
|
|
|
|
|
Iteration cells
|
|
^^^^^^^^^^^^^^^
|
|
|
|
.. code-block:: python
|
|
|
|
rango = sheet['B10:C15']
|
|
for cell in rango:
|
|
app.debug(cell)
|
|
|
|
|
|
Properties
|
|
^^^^^^^^^^
|
|
|
|
is_cell
|
|
~~~~~~~
|
|
|
|
.. code-block:: python
|
|
|
|
cell = sheet['A1']
|
|
app.debug(cell.is_cell)
|
|
|
|
rango = sheet['A1:C5']
|
|
app.debug(rango.is_cell)
|
|
|
|
name
|
|
~~~~
|
|
|
|
Return `AbsoluteName`
|
|
|
|
.. code-block:: python
|
|
|
|
cell = sheet['A1']
|
|
app.debug(cell.name)
|
|
|
|
rango = sheet['A1:C5']
|
|
app.debug(rango.name)
|
|
|
|
address
|
|
~~~~~~~
|
|
|
|
Return struct `com.sun.star.table.CellAddress`
|
|
|
|
.. code-block:: python
|
|
|
|
cell = sheet['A1']
|
|
if cell.is_cell:
|
|
app.debug(cell.address)
|
|
|
|
range_address
|
|
~~~~~~~~~~~~~
|
|
|
|
Return struct `com.sun.star.table.CellRangeAddress`
|
|
|
|
.. code-block:: python
|
|
|
|
rango = sheet['A1:C5']
|
|
if not rango.is_cell:
|
|
app.debug(rango.range_address)
|
|
|
|
sheet
|
|
~~~~~
|
|
|
|
Get parent sheet, return LOCalcSheet class
|
|
|
|
.. code-block:: python
|
|
|
|
rango = sheet['A1:C5']
|
|
sheet = rango.sheet
|
|
app.debug(sheet)
|
|
|
|
doc
|
|
~~~
|
|
|
|
Get parent document, return LODocCalc class
|
|
|
|
.. code-block:: python
|
|
|
|
rango = sheet['A1:C5']
|
|
doc = rango.doc
|
|
app.debug(doc)
|
|
|
|
cursor
|
|
~~~~~~
|
|
|
|
Get cursor by self range, return ScCellCursorObj instance.
|
|
|
|
.. code-block:: python
|
|
|
|
rango = sheet['A1:C5']
|
|
cursor = rango.cursor
|
|
app.debug(cursor.ImplementationName)
|
|
|
|
style
|
|
~~~~~
|
|
|
|
Get or set cell style. Style must exists.
|
|
|
|
.. code-block:: python
|
|
|
|
rango = sheet['A1:C5']
|
|
app.debug(rango.style)
|
|
rango.style = 'Good'
|
|
|
|
|
|
Methods
|
|
^^^^^^^
|