Add support for calc ranges
This commit is contained in:
parent
043e5f5f29
commit
55dfe77aa9
Binary file not shown.
Binary file not shown.
|
@ -9,8 +9,11 @@ Remember, always import library.
|
|||
import easymacro as app
|
||||
|
||||
|
||||
Document
|
||||
~~~~~~~~
|
||||
|
||||
Current doc
|
||||
~~~~~~~~~~~
|
||||
^^^^^^^^^^^
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
|
@ -19,7 +22,7 @@ Current doc
|
|||
|
||||
|
||||
Selection
|
||||
~~~~~~~~~
|
||||
^^^^^^^^^
|
||||
|
||||
* If selection is range get LOCalcRange, if selection is shape get LOShape, other selection get original pyuno object.
|
||||
|
||||
|
@ -31,7 +34,7 @@ Selection
|
|||
|
||||
|
||||
Headers
|
||||
~~~~~~~
|
||||
^^^^^^^
|
||||
|
||||
* Hide or show columns and rows headers.
|
||||
|
||||
|
@ -45,7 +48,7 @@ Headers
|
|||
|
||||
|
||||
Tabs
|
||||
~~~~
|
||||
^^^^
|
||||
|
||||
* Hide or show tab sheets.
|
||||
|
||||
|
@ -59,10 +62,10 @@ Tabs
|
|||
|
||||
|
||||
Sheets
|
||||
^^^^^^
|
||||
~~~~~~
|
||||
|
||||
Active sheet
|
||||
~~~~~~~~~~~~
|
||||
^^^^^^^^^^^^
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
|
@ -75,7 +78,7 @@ Active sheet
|
|||
|
||||
|
||||
Get by index
|
||||
~~~~~~~~~~~~
|
||||
^^^^^^^^^^^^
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
|
@ -85,7 +88,7 @@ Get by index
|
|||
|
||||
|
||||
Get by name
|
||||
~~~~~~~~~~~
|
||||
^^^^^^^^^^^
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
|
@ -95,7 +98,7 @@ Get by name
|
|||
|
||||
|
||||
Contains
|
||||
~~~~~~~~
|
||||
^^^^^^^^
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
|
@ -104,7 +107,7 @@ Contains
|
|||
|
||||
|
||||
Get tuple with all names
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
|
@ -113,7 +116,7 @@ Get tuple with all names
|
|||
|
||||
|
||||
Count
|
||||
~~~~~
|
||||
^^^^^
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
|
@ -121,7 +124,7 @@ Count
|
|||
app.msgbox(len(doc))
|
||||
|
||||
New
|
||||
~~~
|
||||
^^^
|
||||
|
||||
* Always validate if new name not exists.
|
||||
|
||||
|
@ -146,7 +149,7 @@ New
|
|||
|
||||
|
||||
Move
|
||||
~~~~
|
||||
^^^^
|
||||
|
||||
* Move by object to last position.
|
||||
|
||||
|
@ -184,7 +187,7 @@ Move
|
|||
|
||||
|
||||
Remove
|
||||
~~~~~~
|
||||
^^^^^^
|
||||
|
||||
* Remove by object.
|
||||
|
||||
|
@ -208,7 +211,7 @@ Remove
|
|||
|
||||
|
||||
Copy
|
||||
~~~~
|
||||
^^^^
|
||||
|
||||
* Copy inside the same spreadsheet.
|
||||
|
||||
|
@ -234,7 +237,7 @@ Copy
|
|||
|
||||
|
||||
Copy from
|
||||
~~~~~~~~~
|
||||
^^^^^^^^^
|
||||
|
||||
* Copy sheet from one spreadsheet to other.
|
||||
|
||||
|
@ -249,7 +252,7 @@ Copy from
|
|||
|
||||
|
||||
Copy to
|
||||
~~~~~~~
|
||||
^^^^^^^
|
||||
|
||||
* Copy from sheet with the same name
|
||||
|
||||
|
@ -269,7 +272,7 @@ Copy to
|
|||
|
||||
|
||||
Sort
|
||||
~~~~
|
||||
^^^^
|
||||
|
||||
* Sort sheets by names.
|
||||
|
||||
|
@ -279,7 +282,7 @@ Sort
|
|||
doc.sort()
|
||||
|
||||
Name
|
||||
~~~~
|
||||
^^^^
|
||||
|
||||
* Name visible by the user.
|
||||
|
||||
|
@ -292,7 +295,7 @@ Name
|
|||
|
||||
|
||||
Code name
|
||||
~~~~~~~~~
|
||||
^^^^^^^^^
|
||||
|
||||
* Name only accessible by code.
|
||||
|
||||
|
@ -305,7 +308,7 @@ Code name
|
|||
|
||||
|
||||
Visible
|
||||
~~~~~~~
|
||||
^^^^^^^
|
||||
|
||||
* Apply only with spreadsheet with two or more sheets.
|
||||
|
||||
|
@ -319,7 +322,7 @@ Visible
|
|||
|
||||
|
||||
Is protected
|
||||
~~~~~~~~~~~~
|
||||
^^^^^^^^^^^^
|
||||
|
||||
* If sheet is protected with password.
|
||||
|
||||
|
@ -330,7 +333,7 @@ Is protected
|
|||
|
||||
|
||||
Set password
|
||||
~~~~~~~~~~~~
|
||||
^^^^^^^^^^^^
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
|
@ -340,7 +343,7 @@ Set password
|
|||
|
||||
|
||||
Remove password
|
||||
~~~~~~~~~~~~~~~
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
|
@ -353,7 +356,7 @@ Remove password
|
|||
|
||||
|
||||
Tab color
|
||||
~~~~~~~~~
|
||||
^^^^^^^^^
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
|
@ -369,7 +372,7 @@ Tab color
|
|||
|
||||
|
||||
Document parent
|
||||
~~~~~~~~~~~~~~~
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
|
@ -377,7 +380,7 @@ Document parent
|
|||
|
||||
|
||||
Activate
|
||||
~~~~~~~~
|
||||
^^^^^^^^
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
|
@ -392,7 +395,43 @@ Activate
|
|||
sheet.activate()
|
||||
|
||||
|
||||
Ranges
|
||||
~~~~~~
|
||||
|
||||
Cells
|
||||
^^^^^
|
||||
|
||||
* By name
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
sheet = app.active_sheet
|
||||
cell = sheet['A1']
|
||||
app.msgbox(cell.name)
|
||||
|
||||
|
||||
* By position [row, column]
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
cell = sheet[1, 4]
|
||||
app.msgbox(cell.name)
|
||||
|
||||
|
||||
Ranges
|
||||
^^^^^^
|
||||
|
||||
* By name
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
sheet = app.active_sheet
|
||||
rango = sheet['B2:D5']
|
||||
app.msgbox(rango.name)
|
||||
|
||||
* By position [start_row, end_row, start_column, end_column]
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
rango = sheet[1:5,1:4]
|
||||
app.msgbox(rango.name)
|
||||
|
|
|
@ -39,15 +39,17 @@
|
|||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">easymacro</span> <span class="k">as</span> <span class="nn">app</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<section id="document">
|
||||
<h2>Document<a class="headerlink" href="#document" title="Permalink to this headline">¶</a></h2>
|
||||
<section id="current-doc">
|
||||
<h2>Current doc<a class="headerlink" href="#current-doc" title="Permalink to this headline">¶</a></h2>
|
||||
<h3>Current doc<a class="headerlink" href="#current-doc" title="Permalink to this headline">¶</a></h3>
|
||||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">doc</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">active</span>
|
||||
<span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">doc</span><span class="o">.</span><span class="n">type</span><span class="p">)</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</section>
|
||||
<section id="selection">
|
||||
<h2>Selection<a class="headerlink" href="#selection" title="Permalink to this headline">¶</a></h2>
|
||||
<h3>Selection<a class="headerlink" href="#selection" title="Permalink to this headline">¶</a></h3>
|
||||
<ul class="simple">
|
||||
<li><p>If selection is range get LOCalcRange, if selection is shape get LOShape, other selection get original pyuno object.</p></li>
|
||||
</ul>
|
||||
|
@ -58,7 +60,7 @@
|
|||
</div>
|
||||
</section>
|
||||
<section id="headers">
|
||||
<h2>Headers<a class="headerlink" href="#headers" title="Permalink to this headline">¶</a></h2>
|
||||
<h3>Headers<a class="headerlink" href="#headers" title="Permalink to this headline">¶</a></h3>
|
||||
<ul class="simple">
|
||||
<li><p>Hide or show columns and rows headers.</p></li>
|
||||
</ul>
|
||||
|
@ -71,7 +73,7 @@
|
|||
</div>
|
||||
</section>
|
||||
<section id="tabs">
|
||||
<h2>Tabs<a class="headerlink" href="#tabs" title="Permalink to this headline">¶</a></h2>
|
||||
<h3>Tabs<a class="headerlink" href="#tabs" title="Permalink to this headline">¶</a></h3>
|
||||
<ul class="simple">
|
||||
<li><p>Hide or show tab sheets.</p></li>
|
||||
</ul>
|
||||
|
@ -82,12 +84,12 @@
|
|||
<span class="n">doc</span><span class="o">.</span><span class="n">tabs</span> <span class="o">=</span> <span class="ow">not</span> <span class="n">doc</span><span class="o">.</span><span class="n">tabs</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</section>
|
||||
</section>
|
||||
<section id="sheets">
|
||||
<h3>Sheets<a class="headerlink" href="#sheets" title="Permalink to this headline">¶</a></h3>
|
||||
</section>
|
||||
</section>
|
||||
<h2>Sheets<a class="headerlink" href="#sheets" title="Permalink to this headline">¶</a></h2>
|
||||
<section id="active-sheet">
|
||||
<h2>Active sheet<a class="headerlink" href="#active-sheet" title="Permalink to this headline">¶</a></h2>
|
||||
<h3>Active sheet<a class="headerlink" href="#active-sheet" title="Permalink to this headline">¶</a></h3>
|
||||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">sheet</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">active_sheet</span>
|
||||
<span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">sheet</span><span class="o">.</span><span class="n">name</span><span class="p">)</span>
|
||||
|
||||
|
@ -98,7 +100,7 @@
|
|||
</div>
|
||||
</section>
|
||||
<section id="get-by-index">
|
||||
<h2>Get by index<a class="headerlink" href="#get-by-index" title="Permalink to this headline">¶</a></h2>
|
||||
<h3>Get by index<a class="headerlink" href="#get-by-index" title="Permalink to this headline">¶</a></h3>
|
||||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">doc</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">active</span>
|
||||
<span class="n">sheet</span> <span class="o">=</span> <span class="n">doc</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
|
||||
<span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">sheet</span><span class="o">.</span><span class="n">name</span><span class="p">)</span>
|
||||
|
@ -106,7 +108,7 @@
|
|||
</div>
|
||||
</section>
|
||||
<section id="get-by-name">
|
||||
<h2>Get by name<a class="headerlink" href="#get-by-name" title="Permalink to this headline">¶</a></h2>
|
||||
<h3>Get by name<a class="headerlink" href="#get-by-name" title="Permalink to this headline">¶</a></h3>
|
||||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">doc</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">active</span>
|
||||
<span class="n">sheet</span> <span class="o">=</span> <span class="n">doc</span><span class="p">[</span><span class="s1">'Sheet1'</span><span class="p">]</span>
|
||||
<span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">sheet</span><span class="o">.</span><span class="n">name</span><span class="p">)</span>
|
||||
|
@ -114,28 +116,28 @@
|
|||
</div>
|
||||
</section>
|
||||
<section id="contains">
|
||||
<h2>Contains<a class="headerlink" href="#contains" title="Permalink to this headline">¶</a></h2>
|
||||
<h3>Contains<a class="headerlink" href="#contains" title="Permalink to this headline">¶</a></h3>
|
||||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">doc</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">active</span>
|
||||
<span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="s1">'Sheet1'</span> <span class="ow">in</span> <span class="n">doc</span><span class="p">)</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</section>
|
||||
<section id="get-tuple-with-all-names">
|
||||
<h2>Get tuple with all names<a class="headerlink" href="#get-tuple-with-all-names" title="Permalink to this headline">¶</a></h2>
|
||||
<h3>Get tuple with all names<a class="headerlink" href="#get-tuple-with-all-names" title="Permalink to this headline">¶</a></h3>
|
||||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">doc</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">active</span>
|
||||
<span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">doc</span><span class="o">.</span><span class="n">names</span><span class="p">)</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</section>
|
||||
<section id="count">
|
||||
<h2>Count<a class="headerlink" href="#count" title="Permalink to this headline">¶</a></h2>
|
||||
<h3>Count<a class="headerlink" href="#count" title="Permalink to this headline">¶</a></h3>
|
||||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">doc</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">active</span>
|
||||
<span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">doc</span><span class="p">))</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</section>
|
||||
<section id="new">
|
||||
<h2>New<a class="headerlink" href="#new" title="Permalink to this headline">¶</a></h2>
|
||||
<h3>New<a class="headerlink" href="#new" title="Permalink to this headline">¶</a></h3>
|
||||
<ul class="simple">
|
||||
<li><p>Always validate if new name not exists.</p></li>
|
||||
</ul>
|
||||
|
@ -159,7 +161,7 @@
|
|||
</div>
|
||||
</section>
|
||||
<section id="move">
|
||||
<h2>Move<a class="headerlink" href="#move" title="Permalink to this headline">¶</a></h2>
|
||||
<h3>Move<a class="headerlink" href="#move" title="Permalink to this headline">¶</a></h3>
|
||||
<ul class="simple">
|
||||
<li><p>Move by object to last position.</p></li>
|
||||
</ul>
|
||||
|
@ -196,7 +198,7 @@
|
|||
</div>
|
||||
</section>
|
||||
<section id="remove">
|
||||
<h2>Remove<a class="headerlink" href="#remove" title="Permalink to this headline">¶</a></h2>
|
||||
<h3>Remove<a class="headerlink" href="#remove" title="Permalink to this headline">¶</a></h3>
|
||||
<ul class="simple">
|
||||
<li><p>Remove by object.</p></li>
|
||||
</ul>
|
||||
|
@ -219,7 +221,7 @@
|
|||
</div>
|
||||
</section>
|
||||
<section id="copy">
|
||||
<h2>Copy<a class="headerlink" href="#copy" title="Permalink to this headline">¶</a></h2>
|
||||
<h3>Copy<a class="headerlink" href="#copy" title="Permalink to this headline">¶</a></h3>
|
||||
<ul class="simple">
|
||||
<li><p>Copy inside the same spreadsheet.</p></li>
|
||||
<li><p>By object</p></li>
|
||||
|
@ -243,7 +245,7 @@
|
|||
</div>
|
||||
</section>
|
||||
<section id="copy-from">
|
||||
<h2>Copy from<a class="headerlink" href="#copy-from" title="Permalink to this headline">¶</a></h2>
|
||||
<h3>Copy from<a class="headerlink" href="#copy-from" title="Permalink to this headline">¶</a></h3>
|
||||
<ul class="simple">
|
||||
<li><p>Copy sheet from one spreadsheet to other.</p></li>
|
||||
</ul>
|
||||
|
@ -257,7 +259,7 @@
|
|||
</div>
|
||||
</section>
|
||||
<section id="copy-to">
|
||||
<h2>Copy to<a class="headerlink" href="#copy-to" title="Permalink to this headline">¶</a></h2>
|
||||
<h3>Copy to<a class="headerlink" href="#copy-to" title="Permalink to this headline">¶</a></h3>
|
||||
<ul class="simple">
|
||||
<li><p>Copy from sheet with the same name</p></li>
|
||||
</ul>
|
||||
|
@ -276,7 +278,7 @@
|
|||
</div>
|
||||
</section>
|
||||
<section id="sort">
|
||||
<h2>Sort<a class="headerlink" href="#sort" title="Permalink to this headline">¶</a></h2>
|
||||
<h3>Sort<a class="headerlink" href="#sort" title="Permalink to this headline">¶</a></h3>
|
||||
<ul class="simple">
|
||||
<li><p>Sort sheets by names.</p></li>
|
||||
</ul>
|
||||
|
@ -286,7 +288,7 @@
|
|||
</div>
|
||||
</section>
|
||||
<section id="name">
|
||||
<h2>Name<a class="headerlink" href="#name" title="Permalink to this headline">¶</a></h2>
|
||||
<h3>Name<a class="headerlink" href="#name" title="Permalink to this headline">¶</a></h3>
|
||||
<ul class="simple">
|
||||
<li><p>Name visible by the user.</p></li>
|
||||
</ul>
|
||||
|
@ -298,7 +300,7 @@
|
|||
</div>
|
||||
</section>
|
||||
<section id="code-name">
|
||||
<h2>Code name<a class="headerlink" href="#code-name" title="Permalink to this headline">¶</a></h2>
|
||||
<h3>Code name<a class="headerlink" href="#code-name" title="Permalink to this headline">¶</a></h3>
|
||||
<ul class="simple">
|
||||
<li><p>Name only accessible by code.</p></li>
|
||||
</ul>
|
||||
|
@ -310,7 +312,7 @@
|
|||
</div>
|
||||
</section>
|
||||
<section id="visible">
|
||||
<h2>Visible<a class="headerlink" href="#visible" title="Permalink to this headline">¶</a></h2>
|
||||
<h3>Visible<a class="headerlink" href="#visible" title="Permalink to this headline">¶</a></h3>
|
||||
<ul class="simple">
|
||||
<li><p>Apply only with spreadsheet with two or more sheets.</p></li>
|
||||
</ul>
|
||||
|
@ -323,7 +325,7 @@
|
|||
</div>
|
||||
</section>
|
||||
<section id="is-protected">
|
||||
<h2>Is protected<a class="headerlink" href="#is-protected" title="Permalink to this headline">¶</a></h2>
|
||||
<h3>Is protected<a class="headerlink" href="#is-protected" title="Permalink to this headline">¶</a></h3>
|
||||
<ul class="simple">
|
||||
<li><p>If sheet is protected with password.</p></li>
|
||||
</ul>
|
||||
|
@ -333,7 +335,7 @@
|
|||
</div>
|
||||
</section>
|
||||
<section id="set-password">
|
||||
<h2>Set password<a class="headerlink" href="#set-password" title="Permalink to this headline">¶</a></h2>
|
||||
<h3>Set password<a class="headerlink" href="#set-password" title="Permalink to this headline">¶</a></h3>
|
||||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">sheet</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">active_sheet</span>
|
||||
<span class="n">sheet</span><span class="o">.</span><span class="n">password</span> <span class="o">=</span> <span class="s1">'letmein'</span>
|
||||
<span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">sheet</span><span class="o">.</span><span class="n">is_protected</span><span class="p">)</span>
|
||||
|
@ -341,7 +343,7 @@
|
|||
</div>
|
||||
</section>
|
||||
<section id="remove-password">
|
||||
<h2>Remove password<a class="headerlink" href="#remove-password" title="Permalink to this headline">¶</a></h2>
|
||||
<h3>Remove password<a class="headerlink" href="#remove-password" title="Permalink to this headline">¶</a></h3>
|
||||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">sheet</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">active_sheet</span>
|
||||
<span class="n">sheet</span><span class="o">.</span><span class="n">password</span> <span class="o">=</span> <span class="s1">'letmein'</span>
|
||||
<span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">sheet</span><span class="o">.</span><span class="n">is_protected</span><span class="p">)</span>
|
||||
|
@ -352,7 +354,7 @@
|
|||
</div>
|
||||
</section>
|
||||
<section id="tab-color">
|
||||
<h2>Tab color<a class="headerlink" href="#tab-color" title="Permalink to this headline">¶</a></h2>
|
||||
<h3>Tab color<a class="headerlink" href="#tab-color" title="Permalink to this headline">¶</a></h3>
|
||||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">sheet</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">active_sheet</span>
|
||||
<span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">sheet</span><span class="o">.</span><span class="n">color</span><span class="p">)</span>
|
||||
|
||||
|
@ -366,13 +368,13 @@
|
|||
</div>
|
||||
</section>
|
||||
<section id="document-parent">
|
||||
<h2>Document parent<a class="headerlink" href="#document-parent" title="Permalink to this headline">¶</a></h2>
|
||||
<h3>Document parent<a class="headerlink" href="#document-parent" title="Permalink to this headline">¶</a></h3>
|
||||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">doc</span> <span class="o">=</span> <span class="n">sheet</span><span class="o">.</span><span class="n">doc</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</section>
|
||||
<section id="activate">
|
||||
<h2>Activate<a class="headerlink" href="#activate" title="Permalink to this headline">¶</a></h2>
|
||||
<h3>Activate<a class="headerlink" href="#activate" title="Permalink to this headline">¶</a></h3>
|
||||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">doc</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">active</span>
|
||||
<span class="c1"># Get last sheet</span>
|
||||
<span class="n">sheet</span> <span class="o">=</span> <span class="n">doc</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>
|
||||
|
@ -385,6 +387,46 @@
|
|||
</pre></div>
|
||||
</div>
|
||||
</section>
|
||||
</section>
|
||||
<section id="ranges">
|
||||
<h2>Ranges<a class="headerlink" href="#ranges" title="Permalink to this headline">¶</a></h2>
|
||||
<section id="cells">
|
||||
<h3>Cells<a class="headerlink" href="#cells" title="Permalink to this headline">¶</a></h3>
|
||||
<ul class="simple">
|
||||
<li><p>By name</p></li>
|
||||
</ul>
|
||||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">sheet</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">active_sheet</span>
|
||||
<span class="n">cell</span> <span class="o">=</span> <span class="n">sheet</span><span class="p">[</span><span class="s1">'A1'</span><span class="p">]</span>
|
||||
<span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">cell</span><span class="o">.</span><span class="n">name</span><span class="p">)</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<ul class="simple">
|
||||
<li><p>By position [row, column]</p></li>
|
||||
</ul>
|
||||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">cell</span> <span class="o">=</span> <span class="n">sheet</span><span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">4</span><span class="p">]</span>
|
||||
<span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">cell</span><span class="o">.</span><span class="n">name</span><span class="p">)</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</section>
|
||||
<section id="id1">
|
||||
<h3>Ranges<a class="headerlink" href="#id1" title="Permalink to this headline">¶</a></h3>
|
||||
<ul class="simple">
|
||||
<li><p>By name</p></li>
|
||||
</ul>
|
||||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">sheet</span> <span class="o">=</span> <span class="n">app</span><span class="o">.</span><span class="n">active_sheet</span>
|
||||
<span class="n">rango</span> <span class="o">=</span> <span class="n">sheet</span><span class="p">[</span><span class="s1">'B2:D5'</span><span class="p">]</span>
|
||||
<span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">rango</span><span class="o">.</span><span class="n">name</span><span class="p">)</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<ul class="simple">
|
||||
<li><p>By position [start_row, end_row, start_column, end_column]</p></li>
|
||||
</ul>
|
||||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">rango</span> <span class="o">=</span> <span class="n">sheet</span><span class="p">[</span><span class="mi">1</span><span class="p">:</span><span class="mi">5</span><span class="p">,</span><span class="mi">1</span><span class="p">:</span><span class="mi">4</span><span class="p">]</span>
|
||||
<span class="n">app</span><span class="o">.</span><span class="n">msgbox</span><span class="p">(</span><span class="n">rango</span><span class="o">.</span><span class="n">name</span><span class="p">)</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</section>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
|
||||
|
|
|
@ -140,32 +140,9 @@
|
|||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="calc.html">Calc</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="calc.html#current-doc">Current doc</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="calc.html#selection">Selection</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="calc.html#headers">Headers</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="calc.html#tabs">Tabs</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="calc.html#active-sheet">Active sheet</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="calc.html#get-by-index">Get by index</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="calc.html#get-by-name">Get by name</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="calc.html#contains">Contains</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="calc.html#get-tuple-with-all-names">Get tuple with all names</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="calc.html#count">Count</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="calc.html#new">New</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="calc.html#move">Move</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="calc.html#remove">Remove</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="calc.html#copy">Copy</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="calc.html#copy-from">Copy from</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="calc.html#copy-to">Copy to</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="calc.html#sort">Sort</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="calc.html#name">Name</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="calc.html#code-name">Code name</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="calc.html#visible">Visible</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="calc.html#is-protected">Is protected</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="calc.html#set-password">Set password</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="calc.html#remove-password">Remove password</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="calc.html#tab-color">Tab color</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="calc.html#document-parent">Document parent</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="calc.html#activate">Activate</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="calc.html#document">Document</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="calc.html#sheets">Sheets</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="calc.html#ranges">Ranges</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="writer.html">Writer</a><ul>
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -9,8 +9,11 @@ Remember, always import library.
|
|||
import easymacro as app
|
||||
|
||||
|
||||
Document
|
||||
~~~~~~~~
|
||||
|
||||
Current doc
|
||||
~~~~~~~~~~~
|
||||
^^^^^^^^^^^
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
|
@ -19,7 +22,7 @@ Current doc
|
|||
|
||||
|
||||
Selection
|
||||
~~~~~~~~~
|
||||
^^^^^^^^^
|
||||
|
||||
* If selection is range get LOCalcRange, if selection is shape get LOShape, other selection get original pyuno object.
|
||||
|
||||
|
@ -31,7 +34,7 @@ Selection
|
|||
|
||||
|
||||
Headers
|
||||
~~~~~~~
|
||||
^^^^^^^
|
||||
|
||||
* Hide or show columns and rows headers.
|
||||
|
||||
|
@ -45,7 +48,7 @@ Headers
|
|||
|
||||
|
||||
Tabs
|
||||
~~~~
|
||||
^^^^
|
||||
|
||||
* Hide or show tab sheets.
|
||||
|
||||
|
@ -59,10 +62,10 @@ Tabs
|
|||
|
||||
|
||||
Sheets
|
||||
^^^^^^
|
||||
~~~~~~
|
||||
|
||||
Active sheet
|
||||
~~~~~~~~~~~~
|
||||
^^^^^^^^^^^^
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
|
@ -75,7 +78,7 @@ Active sheet
|
|||
|
||||
|
||||
Get by index
|
||||
~~~~~~~~~~~~
|
||||
^^^^^^^^^^^^
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
|
@ -85,7 +88,7 @@ Get by index
|
|||
|
||||
|
||||
Get by name
|
||||
~~~~~~~~~~~
|
||||
^^^^^^^^^^^
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
|
@ -95,7 +98,7 @@ Get by name
|
|||
|
||||
|
||||
Contains
|
||||
~~~~~~~~
|
||||
^^^^^^^^
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
|
@ -104,7 +107,7 @@ Contains
|
|||
|
||||
|
||||
Get tuple with all names
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
|
@ -113,7 +116,7 @@ Get tuple with all names
|
|||
|
||||
|
||||
Count
|
||||
~~~~~
|
||||
^^^^^
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
|
@ -121,7 +124,7 @@ Count
|
|||
app.msgbox(len(doc))
|
||||
|
||||
New
|
||||
~~~
|
||||
^^^
|
||||
|
||||
* Always validate if new name not exists.
|
||||
|
||||
|
@ -146,7 +149,7 @@ New
|
|||
|
||||
|
||||
Move
|
||||
~~~~
|
||||
^^^^
|
||||
|
||||
* Move by object to last position.
|
||||
|
||||
|
@ -184,7 +187,7 @@ Move
|
|||
|
||||
|
||||
Remove
|
||||
~~~~~~
|
||||
^^^^^^
|
||||
|
||||
* Remove by object.
|
||||
|
||||
|
@ -208,7 +211,7 @@ Remove
|
|||
|
||||
|
||||
Copy
|
||||
~~~~
|
||||
^^^^
|
||||
|
||||
* Copy inside the same spreadsheet.
|
||||
|
||||
|
@ -234,7 +237,7 @@ Copy
|
|||
|
||||
|
||||
Copy from
|
||||
~~~~~~~~~
|
||||
^^^^^^^^^
|
||||
|
||||
* Copy sheet from one spreadsheet to other.
|
||||
|
||||
|
@ -249,7 +252,7 @@ Copy from
|
|||
|
||||
|
||||
Copy to
|
||||
~~~~~~~
|
||||
^^^^^^^
|
||||
|
||||
* Copy from sheet with the same name
|
||||
|
||||
|
@ -269,7 +272,7 @@ Copy to
|
|||
|
||||
|
||||
Sort
|
||||
~~~~
|
||||
^^^^
|
||||
|
||||
* Sort sheets by names.
|
||||
|
||||
|
@ -279,7 +282,7 @@ Sort
|
|||
doc.sort()
|
||||
|
||||
Name
|
||||
~~~~
|
||||
^^^^
|
||||
|
||||
* Name visible by the user.
|
||||
|
||||
|
@ -292,7 +295,7 @@ Name
|
|||
|
||||
|
||||
Code name
|
||||
~~~~~~~~~
|
||||
^^^^^^^^^
|
||||
|
||||
* Name only accessible by code.
|
||||
|
||||
|
@ -305,7 +308,7 @@ Code name
|
|||
|
||||
|
||||
Visible
|
||||
~~~~~~~
|
||||
^^^^^^^
|
||||
|
||||
* Apply only with spreadsheet with two or more sheets.
|
||||
|
||||
|
@ -319,7 +322,7 @@ Visible
|
|||
|
||||
|
||||
Is protected
|
||||
~~~~~~~~~~~~
|
||||
^^^^^^^^^^^^
|
||||
|
||||
* If sheet is protected with password.
|
||||
|
||||
|
@ -330,7 +333,7 @@ Is protected
|
|||
|
||||
|
||||
Set password
|
||||
~~~~~~~~~~~~
|
||||
^^^^^^^^^^^^
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
|
@ -340,7 +343,7 @@ Set password
|
|||
|
||||
|
||||
Remove password
|
||||
~~~~~~~~~~~~~~~
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
|
@ -353,7 +356,7 @@ Remove password
|
|||
|
||||
|
||||
Tab color
|
||||
~~~~~~~~~
|
||||
^^^^^^^^^
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
|
@ -369,7 +372,7 @@ Tab color
|
|||
|
||||
|
||||
Document parent
|
||||
~~~~~~~~~~~~~~~
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
|
@ -377,7 +380,7 @@ Document parent
|
|||
|
||||
|
||||
Activate
|
||||
~~~~~~~~
|
||||
^^^^^^^^
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
|
@ -392,7 +395,43 @@ Activate
|
|||
sheet.activate()
|
||||
|
||||
|
||||
Ranges
|
||||
~~~~~~
|
||||
|
||||
Cells
|
||||
^^^^^
|
||||
|
||||
* By name
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
sheet = app.active_sheet
|
||||
cell = sheet['A1']
|
||||
app.msgbox(cell.name)
|
||||
|
||||
|
||||
* By position [row, column]
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
cell = sheet[1, 4]
|
||||
app.msgbox(cell.name)
|
||||
|
||||
|
||||
Ranges
|
||||
^^^^^^
|
||||
|
||||
* By name
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
sheet = app.active_sheet
|
||||
rango = sheet['B2:D5']
|
||||
app.msgbox(rango.name)
|
||||
|
||||
* By position [start_row, end_row, start_column, end_column]
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
rango = sheet[1:5,1:4]
|
||||
app.msgbox(rango.name)
|
||||
|
|
|
@ -1411,6 +1411,16 @@ class LOCalc(LODocument):
|
|||
# ~ return LOCalcDataBaseRanges(self.obj.DataBaseRanges)
|
||||
return self.obj.DatabaseRanges
|
||||
|
||||
@property
|
||||
def ranges(self):
|
||||
obj = self.create_instance('com.sun.star.sheet.SheetCellRanges')
|
||||
return LOCalcRanges(obj)
|
||||
|
||||
def get_ranges(self, address: str):
|
||||
ranges = self.ranges
|
||||
ranges.add([sheet[address] for sheet in self])
|
||||
return ranges
|
||||
|
||||
def activate(self, sheet):
|
||||
obj = sheet
|
||||
if isinstance(sheet, LOCalcSheet):
|
||||
|
@ -2948,6 +2958,49 @@ class LOCalcRange(object):
|
|||
return values
|
||||
|
||||
|
||||
class LOCalcRanges(object):
|
||||
|
||||
def __init__(self, obj):
|
||||
self._obj = obj
|
||||
self._ranges = {}
|
||||
|
||||
def __enter__(self):
|
||||
return self
|
||||
|
||||
def __exit__(self, exc_type, exc_value, traceback):
|
||||
pass
|
||||
|
||||
def __len__(self):
|
||||
return self._obj.Count
|
||||
|
||||
def __contains__(self, item):
|
||||
return self._obj.hasByName(item.name)
|
||||
|
||||
@property
|
||||
def names(self):
|
||||
return self._obj.ElementNames
|
||||
|
||||
@property
|
||||
def data(self):
|
||||
return [r.data for r in self._ranges.values()]
|
||||
|
||||
def add(self, rangos):
|
||||
if isinstance(rangos, LOCalcRange):
|
||||
rangos = (rangos,)
|
||||
for r in rangos:
|
||||
self._ranges[r.name] = r
|
||||
self._obj.addRangeAddress(r.range_address, False)
|
||||
return
|
||||
|
||||
def remove(self, rangos):
|
||||
if isinstance(rangos, LOCalcRange):
|
||||
rangos = (rangos,)
|
||||
for r in rangos:
|
||||
del self._ranges[r.name]
|
||||
self._obj.removeRangeAddress(r.range_address)
|
||||
return
|
||||
|
||||
|
||||
class LOWriterStyles(object):
|
||||
|
||||
def __init__(self, styles):
|
||||
|
|
Loading…
Reference in New Issue