easymacro/docs/source/calc_doc.rst

123 lines
1.8 KiB
ReStructuredText

Active document
---------------
.. code-block:: python
doc = app.active
app.debug(doc.type)
|
Headers
-------
Hide or show columns and rows headers.
.. code-block:: python
doc = app.active
app.msgbox(doc.headers)
doc.headers = not doc.headers
app.msgbox(doc.headers)
doc.headers = not doc.headers
|
Tabs
----
Hide or show tab sheets.
.. code-block:: python
doc = app.active
app.msgbox(doc.tabs)
doc.tabs = not doc.tabs
app.msgbox(doc.tabs)
doc.tabs = not doc.tabs
|
Events
------
See all the events that can be used.
.. code-block:: python
doc = app.active
event_names = doc.events.names
app.debug(event_names)
Assing some macro to event.
.. code-block:: python
doc = app.active
events = doc.events
if 'OnViewClosed' in events:
macro = {'library': 'test', 'name': 'on_view_closed'}
events['OnViewClosed'] = macro
Remove
.. code-block:: python
events['OnViewClosed'] = {}
Or
.. code-block:: python
events.remove('OnViewClosed')
|
Select range by user
--------------------
.. code-block:: python
class Controllers():
def __init__(self, doc):
self.doc = doc
def range_selection_done(self, range_selection):
if range_selection:
app.debug(range_selection)
self.doc.remove_range_selection_listener()
return
def range_selection_aborted(self):
self.doc.remove_range_selection_listener()
return
def main():
doc = app.active
doc.start_range_selection(Controllers)
return
|
Selection
---------
.. code-block:: python
doc = app.active
selection = doc.selection
app.debug(selection.is_cell)
|
Select
------
.. code-block:: python
doc = app.active
cell = doc[0]['A1']
doc.select(cell)