124 lines
1.6 KiB
ReStructuredText
124 lines
1.6 KiB
ReStructuredText
Ranges
|
|
------
|
|
|
|
By selection
|
|
^^^^^^^^^^^^
|
|
|
|
.. code-block:: python
|
|
|
|
doc = app.active
|
|
selection = doc.selection
|
|
app.debug(selection)
|
|
|
|
Count
|
|
^^^^^
|
|
|
|
.. code-block:: python
|
|
|
|
selection = doc.selection
|
|
count = len(selection)
|
|
app.debug(count)
|
|
|
|
Iter
|
|
^^^^
|
|
|
|
.. code-block:: python
|
|
|
|
selection = doc.selection
|
|
for rango in selection:
|
|
app.debug(rango)
|
|
|
|
Get
|
|
^^^
|
|
|
|
* By index
|
|
|
|
.. code-block:: python
|
|
|
|
selection = doc.selection
|
|
rango = selection[1]
|
|
app.debug(rango)
|
|
|
|
* By name
|
|
|
|
.. code-block:: python
|
|
|
|
selection = doc.selection
|
|
rango = selection['Sheet1.D9:E11']
|
|
app.debug(rango)
|
|
|
|
|
|
New ranges container
|
|
^^^^^^^^^^^^^^^^^^^^
|
|
|
|
.. code-block:: python
|
|
|
|
ranges = doc.ranges
|
|
|
|
Add
|
|
^^^
|
|
|
|
.. code-block:: python
|
|
|
|
doc = app.active
|
|
sheet = doc.active
|
|
rangos = doc.ranges
|
|
rangos.add(sheet['A1:B2'])
|
|
rangos.add(sheet['D5:F10'])
|
|
app.debug(rangos)
|
|
|
|
Remove
|
|
^^^^^^
|
|
|
|
.. code-block:: python
|
|
|
|
rangos.remove(sheet['A1:B2'])
|
|
|
|
If contains
|
|
^^^^^^^^^^^
|
|
|
|
.. code-block:: python
|
|
|
|
result = sheet['D5:F10'] in rangos
|
|
app.debug(result)
|
|
|
|
Get same range in all sheets
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
.. code-block:: python
|
|
|
|
rangos = doc.get_ranges('A1:C5')
|
|
app.debug(rangos)
|
|
|
|
Names
|
|
^^^^^
|
|
|
|
.. code-block:: python
|
|
|
|
app.debug(rangos.names)
|
|
|
|
Get and set data
|
|
^^^^^^^^^^^^^^^^
|
|
|
|
.. note::
|
|
|
|
Each range of data must be the exact size of each range.
|
|
|
|
.. code-block:: python
|
|
|
|
rangos = doc.get_ranges('A1:C5')
|
|
data = rangos.data
|
|
app.debug(data)
|
|
rangos.data = data
|
|
|
|
Style
|
|
^^^^^
|
|
|
|
Apply the same style to all ranges.
|
|
|
|
.. code-block:: python
|
|
|
|
rangos = doc.get_ranges('A1:C5')
|
|
rangos.style = 'Good'
|
|
|