403Webshell
Server IP : 121.121.20.254  /  Your IP : 216.73.217.89
Web Server : Microsoft-IIS/10.0
System : Windows NT WEB-SERVER 10.0 build 20348 (Windows Server 2022) AMD64
User : IUSR ( 0)
PHP Version : 8.3.28
Disable Function : NONE
MySQL : ON  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  C:/Program Files/LibreOffice/help/en-US/text/sbasic/shared/03/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : C:/Program Files/LibreOffice/help/en-US/text/sbasic/shared/03/sf_calc.html
<!DOCTYPE html>
<html lang="en-US" dir="ltr">
<head>
<base href="../../../../../">
<noscript><meta http-equiv="refresh" content="0; URL=../../../../../en-US/noscript.html"></noscript>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>SFDocuments.Calc service</title>
<link rel="shortcut icon" href="media/navigation/favicon.ico">
<link type="text/css" href="normalize.css" rel="Stylesheet">
<link type="text/css" href="prism.css" rel="Stylesheet">
<link type="text/css" href="default.css" rel="Stylesheet">
<script type="text/javascript" src="polyfills.js"></script><script type="text/javascript" src="languages.js"></script><script type="text/javascript" src="en-US/langnames.js"></script><script type="text/javascript" src="flexsearch.debug.js"></script><script type="text/javascript" src="prism.js"></script><script type="text/javascript" src="help2.js" defer></script><script type="text/javascript" src="a11y-toggle.js" defer></script><script type="text/javascript" src="paginathing.js" defer></script><script type="text/javascript" src="en-US/bookmarks.js" defer></script><script type="text/javascript" src="en-US/contents.js" defer></script><script type="text/javascript" src="help.js" defer></script><meta name="viewport" content="width=device-width,initial-scale=1">
</head>
<body>
<header id="TopLeftHeader"><a class="symbol" href="en-US/text/shared/05/new_help.html"><div></div></a><a class="logo" href="en-US/text/shared/05/new_help.html"><p dir="auto">LibreOffice 24.2 Help</p></a><div class="dropdowns"><div class="modules">
<button type="button" data-a11y-toggle="modules-nav" id="modules" aria-haspopup="true" aria-expanded="false" aria-controls="modules-nav">Module</button><nav id="modules-nav" hidden=""></nav>
</div></div></header><aside class="leftside"><input id="accordion-1" name="accordion-menu" type="checkbox"><label for="accordion-1" dir="auto">Contents</label><div id="Contents" class="contents-treeview"></div></aside><div id="SearchFrame"><div id="Bookmarks">
<input id="search-bar" type="search" class="search" placeholder="Search in bookmarks for chosen module" dir="auto"><div class="nav-container" tabindex="0"><nav class="index" dir="auto"></nav></div>
</div></div>
<div id="DisplayArea" itemprop="softwareHelp" itemscope="true" itemtype="http://schema.org/SoftwareApplication">
<a name="SFDocuments-sf_calc"></a>
    <a name="bm_id261582733781987"></a>
      <meta itemprop="keywords" content="Calc service">
   


<a name="abstract"></a>
    <h1 id="hd_id731582733781114" dir="auto">
<a name="CalcService"></a><span class="literal">SFDocuments</span>.<span class="literal">Calc</span> service</h1>
    <p id="par_id381589189355849" class="paragraph" dir="auto">The <span class="literal">SFDocuments</span> shared library provides a number of methods and properties to facilitate the management and handling of LibreOffice documents.</p>
    <p id="par_id351591014177269" class="paragraph" dir="auto">The <span class="literal">SFDocuments.Calc</span> service is a subclass of the <a target="_top" href="en-US/text/sbasic/shared/03/sf_document.html"><span class="literal">SFDocuments.Document</span></a> service. All methods and properties defined for the <span class="literal">Document</span> service can also be accessed using a <span class="literal">Calc</span> service instance.</p>
    <p id="par_id591589189364267" class="paragraph" dir="auto">The <span class="literal">Calc</span> service is focused on:</p>
    <ul itemprop="Unordered" itemscope="true" itemtype="http://schema.org/ItemList" dir="auto">
        <li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
            <p id="par_id891589189452545" class="listitem" dir="auto">Handling sheets within a Calc document (copy, insert, move, etc)</p>
        </li>
        <li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
            <p id="par_id811589189463041" class="listitem" dir="auto">Exchanging data between Basic data structures and Calc ranges</p>
        </li>
        <li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
            <p id="par_id141599569935662" class="listitem" dir="auto">Copying and importing massive amounts of data</p>
        </li>
    </ul>

  <div class="note">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/note.svg" alt="note" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id851638217526844" dir="auto">This help page describes methods and properties that are applicable only to Calc documents.</p></div>
</div>
<br>

  <h2 id="hd_id581582885621841" dir="auto">Service invocation</h2>
  <p id="par_id141609955500101" class="paragraph" dir="auto">Before using the <span class="literal">Calc</span> service the <span class="literal">ScriptForge</span> library needs to be loaded or imported:</p>
  <div class="embedded">
<a name="importLibs"></a>
    <div class="note">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/note.svg" alt="note" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id901528999850603" dir="auto">• Basic macros require to load <span class="literal">ScriptForge</span> library using the following statement:<br><span class="literal">GlobalScope.BasicLibraries.loadLibrary("ScriptForge")</span><br><br>• Python scripts require an import from <span class="literal">scriptforge</span> module:<br><span class="literal">from scriptforge import CreateScriptService</span>
    </p></div>
</div>
<br>
  </div>

  <p id="par_id591589191059889" class="paragraph" dir="auto">The <span class="literal">Calc</span> service is closely related to the <span class="literal">UI</span> service of the <span class="literal">ScriptForge</span> library. Below are a few examples of how the <span class="literal">Calc</span> service can be invoked.</p>
  <div class="embedded">
<a name="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">In Basic</h5>
</div>
  <p id="par_id551621623999947" class="paragraph" dir="auto">The code snippet below creates a <span class="literal">Calc</span> service instance that corresponds to the currently active Calc document.</p>
  <div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
    Set oDoc = CreateScriptService("Calc")
  </code></pre></div>
  <p id="par_id341621467500466" class="paragraph" dir="auto">Another way to create an instance of the <span class="literal">Calc</span> service is using the <span class="literal">UI</span> service. In the following example, a new Calc document is created and <span class="literal">oDoc</span> is a <span class="literal">Calc</span> service instance:</p>
  <div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
    Dim ui As Object, oDoc As Object
    Set ui = CreateScriptService("UI")
    Set oDoc = ui.CreateDocument("Calc")
  </code></pre></div>
  <p id="par_id921621467621019" class="paragraph" dir="auto">Or using the <span class="literal">OpenDocument</span> method from the <span class="literal">UI</span> service:</p>
  <div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
    Set oDoc = ui.OpenDocument("C:\Documents\MyFile.ods")
  </code></pre></div>
  <p id="par_id741621467697967" class="paragraph" dir="auto">It is also possible to instantiate the <span class="literal">Calc</span> service specifying a window name for the <span class="literal">CreateScriptService</span> method:</p>
  <div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
    Dim oDoc As Object
    Set oDoc = CreateScriptService("SFDocuments.Calc", "MyFile.ods")
  </code></pre></div>
  <p id="par_id271621467810774" class="paragraph" dir="auto">In the example above, "MyFile.ods" is the name of an open document window. If this argument is not provided, the active window is considered.</p>
  <p id="par_id551658777771853" class="paragraph" dir="auto">It is also possible to invoke the <span class="literal">Calc</span> service using the document referenced by <span class="literal">ThisComponent</span>. This is specially useful when running a macro from within the Basic IDE.</p>
  <div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
    Dim oDoc As Object
    Set oDoc = CreateScriptService("Calc", ThisComponent)
  </code></pre></div>
  <p id="par_id71158288562139" class="paragraph" dir="auto">It is recommended to free resources after use:</p>
  <div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
    Set oDoc = oDoc.Dispose()
  </code></pre></div>
  <p id="par_id231611610666018" class="paragraph" dir="auto">However, if the document was closed using the <span class="literal">CloseDocument</span> method, it becomes unnecessary to free resources using the command described above.</p>
  <div class="embedded">
<a name="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">In Python</h5>
</div>
  <div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
    myDoc = CreateScriptService("Calc")
  </code></pre></div>
  <div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
    ui = CreateScriptService("UI")
    myDoc = ui.CreateDocument("Calc")
  </code></pre></div>
  <div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
    myDoc = ui.OpenDocument(r"C:\Documents\MyFile.ods")
  </code></pre></div>
  <div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
    myDoc = CreateScriptService("SFDocuments.Calc", "MyFile.ods")
    myDoc.Dispose()
  </code></pre></div>
  <div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
    bas = CreateScriptService("Basic")
    myDoc = CreateScriptService("Calc", bas.ThisComponent)
  </code></pre></div>
  <div class="tip">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/tip.svg" alt="tip" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id71611090922315" dir="auto">The use of the prefix "<span class="literal">SFDocuments.</span>" while calling the service is optional.</p></div>
</div>
<br>

  <h2 id="hd_id991591016893982" dir="auto">Definitions</h2>
    <p id="par_id511591016999246" class="paragraph" dir="auto">Many methods require a "<span class="emph">Sheet</span>" or a "<span class="emph">Range</span>" as argument. Single cells are considered a special case of a <span class="literal">Range</span>.</p>
    <p id="par_id511591019278671" class="paragraph" dir="auto">Both may be expressed either as a string or as a reference (= object) depending on the situation:</p>
    <ul itemprop="Unordered" itemscope="true" itemtype="http://schema.org/ItemList" dir="auto">
        <li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
            <p id="par_id571591019367284" class="listitem" dir="auto">Within a <span class="emph">specific</span> <span class="literal">Calc</span> <span class="emph">instance</span>, sheets and ranges are given as strings such as "Sheet1" and "D2:F6".</p>
        </li>
        <li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
            <p id="par_id121591019432157" class="listitem" dir="auto">Additionally, the <span class="literal">.Sheet</span> and <span class="literal">.Range</span> properties return a reference that may be used as argument of a method called from <span class="emph">another instance</span> of the <span class="literal">Calc</span> service.</p>
        </li>
    </ul>
    <div class="embedded">
<a name="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Example:</h3>
</div>
    <p id="par_id421591017227464" class="paragraph" dir="auto">The example below copies data from document A (opened as read-only and hidden) to document B.</p>
  <div class="embedded">
<a name="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">In Basic</h5>
</div>
  <div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
    Dim oDocA As Object, oDocB As Object
    Set oDocA = ui.OpenDocument("C:\Documents\FileA.ods", Hidden := True, ReadOnly := True)
    Set oDocB = ui.OpenDocument("C:\Documents\FileB.ods")
    oDocB.CopyToRange(oDocA.Range("SheetX.D4:F8"), "D2:F6") 'CopyToRange(source, target)
  </code></pre></div>
  <div class="embedded">
<a name="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">In Python</h5>
</div>
  <div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
    docA = ui.OpenDocument(r"C:\Documents\FileA.ods", hidden = True, readonly = True)
    docB = ui.OpenDocument(r"C:\Documents\FileB.ods")
    docB.CopyToRange(docA.Range("SheetX.D4:F8"), "D2:F6")
  </code></pre></div>

    <h3 id="hd_id941591020321580" dir="auto">SheetName</h3>
    <p id="par_id341591020333849" class="paragraph" dir="auto">Either the sheet name as a <span class="literal">string</span> or an <span class="literal">object</span> produced by the <span class="literal">.Sheet</span> property.</p>
    <p id="par_id651591020343023" class="paragraph" dir="auto">The shortcut "~" (tilde) represents the current sheet.</p>
    <h3 id="hd_id101591020737697" dir="auto">RangeName</h3>
    <p id="par_id291591020728110" class="paragraph" dir="auto">Either a string designating a set of contiguous cells located in a sheet of the current instance or an <span class="literal">object</span> produced by the <span class="literal">.Range</span> property.</p>
    <p id="par_id691591020711395" class="paragraph" dir="auto">The shortcut "~" (tilde) represents the current selection or the first selected range if multiple ranges are selected.</p>
    <p id="par_id701592230700986" class="paragraph" dir="auto">The shortcut "*" represents all used cells.</p>
    <p id="par_id641591021597701" class="paragraph" dir="auto">The sheet name is optional when defining a range. If no sheet name is provided, then the active sheet is used. Surrounding single quotes and $ signs are allowed but ignored.</p>
    <p id="par_id231655754032310" class="paragraph" dir="auto">When specifying a <span class="literal">SheetName</span> as a string, the use of single quotes to enclose the sheet name are required if the name contains blank spaces " " or periods ".".  </p>
    <p id="par_id931655906591984" class="paragraph" dir="auto">The examples below illustrate in which cases the use of single quotes is mandatory:</p>
    <div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
      ' The use of single quotes is optional
      oDoc.clearAll("SheetA.A1:B10")
      oDoc.clearAll("'SheetA'.A1:B10")
      ' The use of single quotes is required
      oDoc.clearAll("'Sheet.A'.A1:B10")
    </code></pre></div>
    <div class="tip">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/tip.svg" alt="tip" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id371592406978640" dir="auto">Except for the <span class="literal">CurrentSelection</span> property, the <span class="literal">Calc</span> service considers only single ranges of cells.</p></div>
</div>
<br>
    <table border="1" class="" cellpadding="0" cellspacing="0">
        <tr>
            <th rowspan="" colspan="2" class="tableheadcell" dir="auto">
                <p id="par_id91591025127496" class="tableheadintable" dir="auto">Examples of valid ranges</p>
            </th>
        </tr>
        <tr>
            <td rowspan="" colspan="" dir="auto">
                <p id="par_id481591024294524" class="tablecontentintable" dir="auto">1) $'SheetX'.D2<br>2) $D$2</p>
            </td>
            <td rowspan="" colspan="" dir="auto">
                <p id="par_id721591024294894" class="tablecontentintable" dir="auto">A single cell</p>
            </td>
        </tr>
        <tr>
            <td rowspan="" colspan="" dir="auto">
                <p id="par_id21591024294492" class="tablecontentintable" dir="auto">1) $'SheetX'.D2:F6<br>2) D2:D10</p>
            </td>
            <td rowspan="" colspan="" dir="auto">
                <p id="par_id9159102429464" class="tablecontentintable" dir="auto">Single range with multiple cells</p>
            </td>
        </tr>
        <tr>
            <td rowspan="" colspan="" dir="auto">
                <p id="par_id161592230749179" class="tablecontentintable" dir="auto">$'SheetX'.*</p>
            </td>
            <td rowspan="" colspan="" dir="auto">
                <p id="par_id581592230749243" class="tablecontentintable" dir="auto">All used cells in the given sheet</p>
            </td>
        </tr>
        <tr>
            <td rowspan="" colspan="" dir="auto">
                <p id="par_id641591024294318" class="tablecontentintable" dir="auto">1) $'SheetX'.A:A (column A)<br>2) 3:5 (rows 3 to 5)</p>
            </td>
            <td rowspan="" colspan="" dir="auto">
                <p id="par_id431591024294723" class="tablecontentintable" dir="auto">All cells in contiguous columns or rows up to the last used cell</p>
            </td>
        </tr>
        <tr>
            <td rowspan="" colspan="" dir="auto">
                <p id="par_id871591024294202" class="tablecontentintable" dir="auto">myRange</p>
            </td>
            <td rowspan="" colspan="" dir="auto">
                <p id="par_id721591024294721" class="tablecontentintable" dir="auto">A range named "myRange" at spreadsheet level</p>
            </td>
        </tr>
        <tr>
            <td rowspan="" colspan="" dir="auto">
                <p id="par_id181591024294534" class="tablecontentintable" dir="auto">1) ~.someRange<br>2) SheetX.someRange</p>
            </td>
            <td rowspan="" colspan="" dir="auto">
                <p id="par_id911591024294816" class="tablecontentintable" dir="auto">A range name at sheet level</p>
            </td>
        </tr>
        <tr>
            <td rowspan="" colspan="" dir="auto">
                <p id="par_id781591024294621" class="tablecontentintable" dir="auto">myDoc.Range("SheetX.D2:F6") </p>
            </td>
            <td rowspan="" colspan="" dir="auto">
                <p id="par_id681591024294568" class="tablecontentintable" dir="auto">A range within the sheet SheetX in file associated with the myDoc Calc instance</p>
            </td>
        </tr>
      <tr>
            <td rowspan="" colspan="" dir="auto">
                <p id="par_id101591024294151" class="tablecontentintable" dir="auto">~.~ or ~</p>
            </td>
            <td rowspan="" colspan="" dir="auto">
                <p id="par_id22159102429479" class="tablecontentintable" dir="auto">The current selection in the active sheet</p>
            </td>
        </tr>
    </table>
<br>

  <h2 id="hd_id351582885195476" dir="auto">Properties</h2>
  <p id="par_id151591018231905" class="paragraph" dir="auto">All the properties generic to any document are implicitly applicable also to Calc documents. For more information, read the <a target="_top" href="en-US/text/sbasic/shared/03/sf_document.html">Document service Help page</a>.</p>
  <p id="par_id911591018242565" class="paragraph" dir="auto">The properties specifically available for Calc documents are:</p>
  <a name="properties_toc"></a>
  <table border="1" class="" cellpadding="0" cellspacing="0">
    <tr>
        <th rowspan="" colspan="" class="tableheadcell" dir="auto">
            <p id="par_id41582885195836" class="tableheadintable" dir="auto">Name</p>
        </th>
        <th rowspan="" colspan="" class="tableheadcell" dir="auto">
            <p id="par_id31582885195372" class="tableheadintable" dir="auto">Readonly</p>
        </th>
        <th rowspan="" colspan="" class="tableheadcell" dir="auto">
            <p id="par_id221591018408168" class="tableheadintable" dir="auto">Argument</p>
        </th>
        <th rowspan="" colspan="" class="tableheadcell" dir="auto">
            <p id="par_id31582885195238" class="tableheadintable" dir="auto">Return type</p>
        </th>
        <th rowspan="" colspan="" class="tableheadcell" dir="auto">
            <p id="par_id931582885195131" class="tableheadintable" dir="auto">Description</p>
        </th>
    </tr>
    <tr>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id681592407165508" class="tablecontentintable" dir="auto">CurrentSelection</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id301592407165942" class="tablecontentintable" dir="auto">No</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id81592407165611" class="tablecontentintable" dir="auto">None</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id59159240716522" class="tablecontentintable" dir="auto">String or array of strings</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id85159240716560" class="tablecontentintable" dir="auto">The single selected range as a string or the list of selected ranges as an array.</p>
        </td>
    </tr>
    <tr>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id681592407165201" class="tablecontentintable" dir="auto">FirstCell</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id301592407165606" class="tablecontentintable" dir="auto">Yes</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id81592407165545" class="tablecontentintable" dir="auto">SheetName or RangeName as String</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id59159240716378" class="tablecontentintable" dir="auto">String</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id85159240716828" class="tablecontentintable" dir="auto">Returns the first used cell in a given range or sheet.</p>
        </td>
    </tr>
    <tr>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id681592407166918" class="tablecontentintable" dir="auto">FirstColumn</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id301592407166642" class="tablecontentintable" dir="auto">Yes</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id81592407165145" class="tablecontentintable" dir="auto">SheetName or RangeName as String</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id59159240716125" class="tablecontentintable" dir="auto">Long</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id85159240716225" class="tablecontentintable" dir="auto">Returns the leftmost column number in a given range or sheet.</p>
        </td>
    </tr>
    <tr>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id681592407169888" class="tablecontentintable" dir="auto">FirstRow</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id301592407167972" class="tablecontentintable" dir="auto">Yes</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id81592407165695" class="tablecontentintable" dir="auto">SheetName or RangeName as String</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id59159240716663" class="tablecontentintable" dir="auto">Long</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id85159240716128" class="tablecontentintable" dir="auto">Returns the topmost row number in a given range or sheet.</p>
        </td>
    </tr>
    <tr>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id521593094953943" class="tablecontentintable" dir="auto">Height</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id101593094953259" class="tablecontentintable" dir="auto">Yes</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id741593094953790" class="tablecontentintable" dir="auto">RangeName As String</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id581593094953195" class="tablecontentintable" dir="auto">Long</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id311593094953330" class="tablecontentintable" dir="auto">The number of rows (&gt;= 1) in the given range.</p>
        </td>
    </tr>
    <tr>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id97158288519551" class="tablecontentintable" dir="auto">LastCell</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id221582885195686" class="tablecontentintable" dir="auto">Yes</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id501591018870619" class="tablecontentintable" dir="auto">SheetName or RangeName as String</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id371582885195525" class="tablecontentintable" dir="auto">String</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id881582885195976" class="tablecontentintable" dir="auto">Returns the last used cell in a given range or sheet.</p>
        </td>
    </tr>
    <tr>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id261592315106411" class="tablecontentintable" dir="auto">LastColumn</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id601592315106598" class="tablecontentintable" dir="auto">Yes</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id831592315106202" class="tablecontentintable" dir="auto">SheetName or RangeName as String</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id591592315106615" class="tablecontentintable" dir="auto">Long</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id791592315106790" class="tablecontentintable" dir="auto">The last used column in a given range or sheet.</p>
        </td>
    </tr>
    <tr>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id801591025591570" class="tablecontentintable" dir="auto">LastRow</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id981591025591597" class="tablecontentintable" dir="auto">Yes</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id81591025591696" class="tablecontentintable" dir="auto">SheetName or RangeName as String</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id61591025591572" class="tablecontentintable" dir="auto">Long</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id421591025591509" class="tablecontentintable" dir="auto">The last used row in a given range or sheet.</p>
        </td>
    </tr>
    <tr>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id52159102559144" class="tablecontentintable" dir="auto">Range</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id81591025591672" class="tablecontentintable" dir="auto">Yes</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id561591025591239" class="tablecontentintable" dir="auto">RangeName As String</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id311591025591598" class="tablecontentintable" dir="auto">Object</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id571591025591367" class="tablecontentintable" dir="auto">A range reference that can be used as argument of methods like <span class="literal">CopyToRange</span>.</p>
        </td>
    </tr>
    <tr>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id52159102559323" class="tablecontentintable" dir="auto">Region</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id81591025591007" class="tablecontentintable" dir="auto">Yes</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id561591025592149" class="tablecontentintable" dir="auto">RangeName As String</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id311591025591078" class="tablecontentintable" dir="auto">String</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
          <p id="par_id571591025599937" class="tablecontentintable" dir="auto">Returns the address of the smallest area that contains the specified range so that the area is surrounded by empty cells or sheet edges. This is equivalent to applying the <span id="swlnsyssf_calc_1" class="switchinline"><span hidden="true" id="MACsf_calc_1" class="MAC"><span class="keycode">Command + *</span></span><span hidden="true" id="defaultsf_calc_1"><span class="keycode">Ctrl + *</span></span></span> shortcut to the given range.</p>
        </td>
    </tr>
    <tr>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id17159102559142" class="tablecontentintable" dir="auto">Sheet</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id541591025591511" class="tablecontentintable" dir="auto">Yes</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id661591025591903" class="tablecontentintable" dir="auto">SheetName As String</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id101591025591982" class="tablecontentintable" dir="auto">Object</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id731591025591753" class="tablecontentintable" dir="auto">A sheet reference that can be used as argument of methods like <span class="literal">CopySheet</span>.</p>
        </td>
    </tr>
    <tr>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id171591025595653" class="tablecontentintable" dir="auto">SheetName</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id541591025591322" class="tablecontentintable" dir="auto">Yes</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id661591025591188" class="tablecontentintable" dir="auto">RangeName As String</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id101591025591289" class="tablecontentintable" dir="auto">String</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id731591025591006" class="tablecontentintable" dir="auto">Returns the sheet name of a given range address.</p>
        </td>
    </tr>
    <tr>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id591591025591635" class="tablecontentintable" dir="auto">Sheets</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id581591025591579" class="tablecontentintable" dir="auto">Yes</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id751591025591667" class="tablecontentintable" dir="auto">None</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id861591025591250" class="tablecontentintable" dir="auto">Array of strings</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id491591025591370" class="tablecontentintable" dir="auto">The list with the names of all existing sheets.</p>
        </td>
    </tr>
    <tr>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id731593095062923" class="tablecontentintable" dir="auto">Width</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id711593095062771" class="tablecontentintable" dir="auto">Yes</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id311593095062171" class="tablecontentintable" dir="auto">RangeName As String</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id761593095062827" class="tablecontentintable" dir="auto">Long</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id681593095062358" class="tablecontentintable" dir="auto">The number of columns (&gt;= 1) in the given range.</p>
        </td>
    </tr>
    <tr>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id691592315404547" class="tablecontentintable" dir="auto">XCellRange</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id391592315404944" class="tablecontentintable" dir="auto">Yes</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id1001592315404525" class="tablecontentintable" dir="auto">RangeName As String</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id7715923154041" class="tablecontentintable" dir="auto">Object</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id321592315404430" class="tablecontentintable" dir="auto">A <span class="literal">com.sun.star.Table.XCellRange</span> UNO object.</p>
        </td>
    </tr>
    <tr>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id961592315565332" class="tablecontentintable" dir="auto">XSheetCellCursor</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id501592315567199" class="tablecontentintable" dir="auto">Yes</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id411592315560025" class="tablecontentintable" dir="auto">RangeName As String</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id521592315565365" class="tablecontentintable" dir="auto">Object</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id41592315565185" class="tablecontentintable" dir="auto">A <span class="literal">com.sun.star.sheet.XSheetCellCursor</span> UNO object. After moving the cursor, the resulting range address can be accessed through the <span class="literal">AbsoluteName</span> UNO property of the cursor object, which returns a string value that can be used as argument for properties and methods of the Calc service.</p>
        </td>
    </tr>
    <tr>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id961592315565156" class="tablecontentintable" dir="auto">XSpreadsheet</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id501592315565569" class="tablecontentintable" dir="auto">Yes</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id411592315565235" class="tablecontentintable" dir="auto">SheetName As String</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id521592315565269" class="tablecontentintable" dir="auto">Object</p>
        </td>
        <td rowspan="" colspan="" dir="auto">
            <p id="par_id41592315560095" class="tablecontentintable" dir="auto">A <span class="literal">com.sun.star.sheet.XSpreadsheet</span> UNO object.</p>
        </td>
    </tr>
  </table>
<br>
  

  <div class="tip">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/tip.svg" alt="tip" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id321611613059105" dir="auto">Visit LibreOffice API Documentation's website to learn more about <a target="_blank" href="https://api.libreoffice.org/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1table_1_1XCellRange.html">XCellRange</a>, <a target="_blank" href="https://api.libreoffice.org/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1sheet_1_1XSheetCellCursor.html">XSheetCellCursor</a> and <a target="_blank" href="https://api.libreoffice.org/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1sheet_1_1XSpreadsheet.html">XSpreadsheet</a> UNO objects.</p></div>
</div>
<br>

  <h2 id="hd_id501582887473754" dir="auto">Methods</h2>
  <a name="methods_toc"></a>
  <table border="1" class="" cellpadding="0" cellspacing="0">
   <tr>
     <th rowspan="" colspan="3" class="tableheadcell" dir="auto">
       <p id="par_id891611613601554" class="tableheadintable" dir="auto">List of Methods in the Calc Service</p>
     </th>
   </tr>
   <tr>
       <td rowspan="" colspan="" dir="auto">
           <p id="par_id891611613601556" class="tablecontentintable" dir="auto">
             <a target="_top" href="en-US/text/sbasic/shared/03/sf_calc.html#A1Style">A1Style</a><br>
             <a target="_top" href="en-US/text/sbasic/shared/03/sf_calc.html#Activate">Activate</a><br>
             <a target="_top" href="en-US/text/sbasic/shared/03/sf_calc.html#Charts">Charts</a><br>
             <a target="_top" href="en-US/text/sbasic/shared/03/sf_calc.html#ClearAll">ClearAll</a><br>
             <a target="_top" href="en-US/text/sbasic/shared/03/sf_calc.html#ClearFormats">ClearFormats</a><br>
             <a target="_top" href="en-US/text/sbasic/shared/03/sf_calc.html#ClearValues">ClearValues</a><br>
             <a target="_top" href="en-US/text/sbasic/shared/03/sf_calc.html#CompactLeft">CompactLeft</a><br>
             <a target="_top" href="en-US/text/sbasic/shared/03/sf_calc.html#CompactUp">CompactUp</a><br>
             <a target="_top" href="en-US/text/sbasic/shared/03/sf_calc.html#CopySheet">CopySheet</a><br>
             <a target="_top" href="en-US/text/sbasic/shared/03/sf_calc.html#CopySheetFromFile">CopySheetFromFile</a><br>
             <a target="_top" href="en-US/text/sbasic/shared/03/sf_calc.html#CopyToCell">CopyToCell</a><br>
             <a target="_top" href="en-US/text/sbasic/shared/03/sf_calc.html#CopyToRange">CopyToRange</a><br>
             <a target="_top" href="en-US/text/sbasic/shared/03/sf_calc.html#CreateChart">CreateChart</a><br>
             <a target="_top" href="en-US/text/sbasic/shared/03/sf_calc.html#CreatePivotTable">CreatePivotTable</a><br>
             <a target="_top" href="en-US/text/sbasic/shared/03/sf_calc.html#DAvg">DAvg</a><br>
           </p>
       </td>
       <td rowspan="" colspan="" dir="auto">
           <p id="par_id541611613601554" class="tablecontentintable" dir="auto">
             <a target="_top" href="en-US/text/sbasic/shared/03/sf_calc.html#DAvg">DCount</a><br>
             <a target="_top" href="en-US/text/sbasic/shared/03/sf_calc.html#DAvg">DMax</a><br>
             <a target="_top" href="en-US/text/sbasic/shared/03/sf_calc.html#DAvg">DMin</a><br>
             <a target="_top" href="en-US/text/sbasic/shared/03/sf_calc.html#DAvg">DSum</a><br>
             <a target="_top" href="en-US/text/sbasic/shared/03/sf_calc.html#ExportRangeToFile">ExportRangeToFile</a><br>
             <a target="_top" href="en-US/text/sbasic/shared/03/sf_calc.html#Forms">Forms</a><br>
             <a target="_top" href="en-US/text/sbasic/shared/03/sf_calc.html#GetColumnName">GetColumnName</a><br>
             <a target="_top" href="en-US/text/sbasic/shared/03/sf_calc.html#GetFormula">GetFormula</a><br>
             <a target="_top" href="en-US/text/sbasic/shared/03/sf_calc.html#GetValue">GetValue</a><br>
             <a target="_top" href="en-US/text/sbasic/shared/03/sf_calc.html#ImportFromCSVFile">ImportFromCSVFile</a><br>
             <a target="_top" href="en-US/text/sbasic/shared/03/sf_calc.html#ImportFromDatabase">ImportFromDatabase</a><br>
             <a target="_top" href="en-US/text/sbasic/shared/03/sf_calc.html#InsertSheet">InsertSheet</a><br>
             <a target="_top" href="en-US/text/sbasic/shared/03/sf_calc.html#MoveRange">MoveRange</a><br>
             <a target="_top" href="en-US/text/sbasic/shared/03/sf_calc.html#MoveSheet">MoveSheet</a><br>
             <a target="_top" href="en-US/text/sbasic/shared/03/sf_calc.html#Offset">Offset</a><br>
           </p>
       </td>
       <td rowspan="" colspan="" dir="auto">
           <p id="par_id701611613601554" class="tablecontentintable" dir="auto">
             <a target="_top" href="en-US/text/sbasic/shared/03/sf_calc.html#OpenRangeSelector">OpenRangeSelector</a><br>
             <a target="_top" href="en-US/text/sbasic/shared/03/sf_calc.html#PrintOut">PrintOut</a><br>
             <a target="_top" href="en-US/text/sbasic/shared/03/sf_calc.html#Printf">Printf</a><br>
             <a target="_top" href="en-US/text/sbasic/shared/03/sf_calc.html#RemoveDuplicates">RemoveDuplicates</a><br>
             <a target="_top" href="en-US/text/sbasic/shared/03/sf_calc.html#RemoveSheet">RemoveSheet</a><br>
             <a target="_top" href="en-US/text/sbasic/shared/03/sf_calc.html#RenameSheet">RenameSheet</a><br>
             <a target="_top" href="en-US/text/sbasic/shared/03/sf_calc.html#SetArray">SetArray</a><br>
             <a target="_top" href="en-US/text/sbasic/shared/03/sf_calc.html#SetCellStyle">SetCellStyle</a><br>
             <a target="_top" href="en-US/text/sbasic/shared/03/sf_calc.html#SetFormula">SetFormula</a><br>
             <a target="_top" href="en-US/text/sbasic/shared/03/sf_calc.html#SetValue">SetValue</a><br>
             <a target="_top" href="en-US/text/sbasic/shared/03/sf_calc.html#ShiftDown">ShiftDown</a><br>
             <a target="_top" href="en-US/text/sbasic/shared/03/sf_calc.html#ShiftLeft">ShiftLeft</a><br>
             <a target="_top" href="en-US/text/sbasic/shared/03/sf_calc.html#ShiftRight">ShiftRight</a><br>
             <a target="_top" href="en-US/text/sbasic/shared/03/sf_calc.html#ShiftUp">ShiftUp</a><br>
             <a target="_top" href="en-US/text/sbasic/shared/03/sf_calc.html#SortRange">SortRange</a><br>
           </p>
       </td>
   </tr>
  </table>
<br>
  

<a name="A1Style"></a>
  
  <a name="bm_id92158919969104"></a>
    <meta itemprop="keywords" content="Calc service,A1Style">
  
  <h2 id="hd_id201589199698251" dir="auto">A1Style</h2>
  <p id="par_id93158919969228" class="paragraph" dir="auto">Returns a range address as a string based on sheet coordinates, i.e. row and column numbers.</p>
  <p id="par_id21635434153216" class="paragraph" dir="auto">If only a pair of coordinates is given, then an address to a single cell is returned. Additional arguments can specify the bottom-right cell of a rectangular range.</p>
  <div class="embedded">
<a name="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Syntax:</h3>
</div>
  <p id="par_id821621534014334" class="paragraph" dir="auto">
    <span class="input" data-tooltip="Click on text to copy to clipboard">svc.A1Style(row1: int, column1: int, row2: int = 0; column2: int = 0; sheetname: str = "~"): str</span>
  </p>
  <div class="embedded">
<a name="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parameters:</h3>
</div>
  <p id="par_id821591631203080" class="paragraph" dir="auto"><span class="emph">row1, column1</span>: Specify the row and column numbers of the top-left cell in the range to be considered. Row and column numbers start at 1.</p>
  <p id="par_id821591631203212" class="paragraph" dir="auto"><span class="emph">row2, column2</span>: Specify the row and column numbers of the bottom-right cell in the range to be considered. If these arguments are not provided, or if values smaller than <span class="literal">row1</span> and <span class="literal">column1</span> are given, then the address of the single cell range represented by <span class="literal">row1</span> and <span class="literal">column1</span> is returned.</p>
  <p id="par_id821591631203336" class="paragraph" dir="auto"><span class="emph">sheetname</span>: The name of the sheet to be appended to the returned range address. The sheet must exist. The default value is "~" corresponding to the currently active sheet.</p>
  <div class="embedded">
<a name="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Example:</h3>
</div>
  <p id="par_id131611616623705" class="paragraph" dir="auto">The examples below in Basic and Python consider that "Sheet1" is the currently active sheet.</p>
  <div class="embedded">
<a name="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">In Basic</h5>
</div>
  <div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
    Set oDoc = CreateScriptService("Calc")
    addr1 = oDoc.A1Style(1, 1) ' '$Sheet1'.$A$1
    addr2 = oDoc.A1Style(2, 2, 3, 6) ' '$Sheet1'.$B$2:$F$3
    addr3 = oDoc.A1Style(2, 2, 0, 6) ' '$Sheet1'.$B$2
    addr4 = oDoc.A1Style(3, 4, 3, 8, "Sheet2") ' '$Sheet2'.$D$3:$H$3
    addr5 = oDoc.A1Style(5, 1, SheetName := "Sheet3") ' '$Sheet3'.$A$5
  </code></pre></div>
  <div class="embedded">
<a name="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">In Python</h5>
</div>
  <div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
    doc = CreateScriptService("Calc")
    addr1 = doc.A1Style(1, 1) # '$Sheet1'.$A$1
    addr2 = doc.A1Style(2, 2, 3, 6) # '$Sheet1'.$B$2:$F$3
    addr3 = doc.A1Style(2, 2, 0, 6) # '$Sheet1'.$B$2
    addr4 = doc.A1Style(3, 4, 3, 8, "Sheet2") # '$Sheet2'.$D$3:$H$3
    addr5 = doc.A1Style(5, 1, sheetname="Sheet3") # '$Sheet3'.$A$5
  </code></pre></div>
  <div class="tip">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/tip.svg" alt="tip" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id501611617808112" dir="auto">The method <span class="literal">A1Style</span> can be combined with any of the many properties and methods of the Calc service that require a range as argument, such as <span class="literal">GetValue</span>, <span class="literal">GetFormula</span>, <span class="literal">ClearAll</span>, etc.</p></div>
</div>
<br>


<a name="Activate"></a>
  
  <a name="bm_id92158919969883"></a>
      <meta itemprop="keywords" content="Calc service,Activate">
  
  <h2 id="hd_id201589199698099" dir="auto">Activate</h2>
  <p id="par_id93158919969864" class="paragraph" dir="auto">If the argument <span class="literal">sheetname</span> is provided, the given sheet is activated and it becomes the currently selected sheet. If the argument is absent, then the document window is activated.</p>
  <div class="embedded">
<a name="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Syntax:</h3>
</div>
  <p id="par_id821621534014732" class="paragraph" dir="auto">
    <span class="input" data-tooltip="Click on text to copy to clipboard">svc.Activate(sheetname: str = ""): bool</span>
  </p>
  <div class="embedded">
<a name="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parameters:</h3>
</div>
  <p id="par_id821591631203996" class="paragraph" dir="auto"><span class="emph">sheetname</span>: The name of the sheet to be activated in the document. The default value is an empty string, meaning that the document window will be activated without changing the active sheet.</p>
  <div class="embedded">
<a name="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Example:</h3>
</div>
  <p id="par_id131611616623714" class="paragraph" dir="auto">The example below activates the sheet named "Sheet4" in the currently active document.</p>
  <div class="embedded">
<a name="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">In Basic</h5>
</div>
  <div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
    Dim ui as Variant, oDoc as Object
    Set ui = CreateScriptService("UI")
    Set oDoc = ui.GetDocument(ui.ActiveWindow)
    oDoc.Activate("Sheet4")
  </code></pre></div>
  <div class="embedded">
<a name="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">In Python</h5>
</div>
  <div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
    ui = CreateScriptService("UI")
    myDoc = ui.GetDocument(ui.ActiveWindow)
    myDoc.Activate("Sheet4")
  </code></pre></div>
  <div class="tip">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/tip.svg" alt="tip" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id501611617808220" dir="auto">Activating a sheet makes sense only if it is performed on a Calc document. To make sure you have a Calc document at hand you can use the <span class="literal">isCalc</span> property of the document object, which returns <span class="literal">True</span> if it is a Calc document and <span class="literal">False</span> otherwise.</p></div>
</div>
<br>


<a name="Charts"></a>
  
  <a name="bm_id92158915960183"></a>
      <meta itemprop="keywords" content="Calc service,Charts">
  
  <h2 id="hd_id201589199698104" dir="auto">Charts</h2>
  <p id="par_id93158919969856" class="paragraph" dir="auto">Returns either the list with the names of all chart objects in a given sheet or a single <span class="literal">Chart</span> service instance.</p>
  <ul itemprop="Unordered" itemscope="true" itemtype="http://schema.org/ItemList" dir="auto">
    <li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
      <p id="par_id371635438503202" class="listitem" dir="auto">If only <span class="literal">sheetname</span> is specified, a zero-based array of strings containing the names of all charts is returned.</p>
    </li>
    <li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
      <p id="par_id371635438509045" class="listitem" dir="auto">If a <span class="literal">chartname</span> is provided, then a single object corresponding to the desired chart is returned. The specified chart must exist.</p>
    </li>
  </ul>
  <div class="embedded">
<a name="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Syntax:</h3>
</div>
  <p id="par_id821621534028832" class="paragraph" dir="auto">
    <span class="input" data-tooltip="Click on text to copy to clipboard">svc.Charts(sheetname: str, chartname: str = ""): obj</span>
  </p>
  <div class="embedded">
<a name="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parameters:</h3>
</div>
  <p id="par_id821591631205026" class="paragraph" dir="auto"><span class="emph">sheetname</span>: The name of the sheet from which the list of charts is to be retrieved or where the specified chart is located.</p>
  <p id="par_id821591631203566" class="paragraph" dir="auto"><span class="emph">chartname</span>: The user-defined name of the chart object to be returned. If the chart does not have a user-defined name, then the internal object name can be used. If this argument is absent, then the list of chart names in the specified sheet is returned.</p>
  <div class="tip">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/tip.svg" alt="tip" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id431635438771588" dir="auto">Use the <span class="menuitem">Navigator</span> sidebar to check the names assigned to charts under the <span class="menuitem">OLE objects</span> category.</p></div>
</div>
<br>
  <div class="embedded">
<a name="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Example:</h3>
</div>
  <div class="embedded">
<a name="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">In Basic</h5>
</div>
  <p id="par_id41635439328174" class="paragraph" dir="auto">The example below shows the number of chart objects in "Sheet1".</p>
  <div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
    Dim arrNames as Object
    arrNames = oDoc.Charts("Sheet1")
    MsgBox "There are " &amp; UBound(arrNames) + 1 &amp; " charts in Sheet1"
  </code></pre></div>
  <p id="par_id571635439417400" class="paragraph" dir="auto">The following example accesses the chart named "MyChart" in "Sheet1" and prints its type.</p>
  <div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
    Dim oChart as Object
    oChart = oDoc.Charts("Sheet1", "MyChart")
    MsgBox oChart.ChartType
  </code></pre></div>
  <div class="embedded">
<a name="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">In Python</h5>
</div>
  <div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
    bas = CreateScriptService("Basic")
    chart_names = doc.Charts("Sheet1")
    bas.MsgBox(f"There are {len(chart_names)} charts in Sheet1")
  </code></pre></div>
  <div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
    chart = doc.Charts("Sheet1", "MyChart")
    bas.MsgBox(chart.ChartType)
  </code></pre></div>


<a name="ClearAll"></a>
  
  <a name="bm_id231592919577434"></a>
      <meta itemprop="keywords" content="Calc service,ClearAll">
  
  <h2 id="hd_id921592919577158" dir="auto">ClearAll</h2>
  <p id="par_id31592919577984" class="paragraph" dir="auto">Clears all the contents and formats of the given range.</p>
  <p id="par_id961670941803758" class="paragraph" dir="auto">A filter formula can be specified to determine which cells shall be affected.</p>
  <div class="embedded">
<a name="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Syntax:</h3>
</div>
  <p id="par_id441621534763020" class="paragraph" dir="auto">
    <span class="input" data-tooltip="Click on text to copy to clipboard">svc.ClearAll(range: str, opt filterformula: str, opt filterscope: str)</span>
  </p>
  <div class="embedded">
<a name="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parameters:</h3>
</div>
  <p id="par_id441592919577809" class="paragraph" dir="auto"><span class="emph">range:</span> The range to be cleared, as a string.</p>
  <a name="filterformula_desc"></a>
    <p id="par_id351670939954166" class="paragraph" dir="auto"><span class="emph">filterformula:</span> A Calc formula that shall be applied to the given range to determine which cells will be affected. The specified formula must return <span class="literal">True</span> or <span class="literal">False</span>. If this argument is not specified, then all cells in the range are affected.</p>
    <p id="par_id461670939954392" class="paragraph" dir="auto"><span class="emph">filterscope:</span> Determines how <span class="literal">filterformula</span> is expanded to the given range. This argument is mandatory if a <span class="literal">filterformula</span> is specified. The following values are accepted:</p>
    <ul itemprop="Unordered" itemscope="true" itemtype="http://schema.org/ItemList" dir="auto">
      <li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
        <p id="par_id991670941074213" class="listitem" dir="auto"><span class="emph">"CELL":</span> The formula specified in the <span class="literal">filterformula</span> argument is expanded once for each cell in <span class="literal">range</span>.</p>
      </li>
      <li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
        <p id="par_id911670941074926" class="listitem" dir="auto"><span class="emph">"ROW":</span> The formula specified in the <span class="literal">filterformula</span> argument is expanded once for each row in <span class="literal">range</span>.</p>
      </li>
      <li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
        <p id="par_id581670941075101" class="listitem" dir="auto"><span class="emph">"COLUMN":</span> The formula specified in the <span class="literal">filterformula</span> argument is expanded once for each column in <span class="literal">range</span>.</p>
      </li>
    </ul>
  
  <div class="embedded">
<a name="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Example:</h3>
</div>
  <div class="embedded">
<a name="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">In Basic</h5>
</div>
  <div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
    ' Clears all cells in the range SheetX.A1:J10
    oDoc.ClearAll("SheetX.A1:J10")
    ' Clears all cells in the range SheetX.A1:J10 that have a value greater than 100
    oDoc.ClearAll("SheetX.A1:J10", "=SheetX.A1&gt;100", "CELL")
    ' Clears all rows in the range SheetX.A1:J10 whose sum is greater than 500
    oDoc.ClearAll("SheetX.A1:J10", "=SUM(SheetX.A1:J1)&gt;100", "ROW")
    ' Clears all columns in the range SheetX.A1:J10 whose sum is greater than 500
    oDoc.ClearAll("SheetX.A1:J10", "=SUM(SheetX.A1:A10)&gt;100", "COLUMN")
  </code></pre></div>
  <div class="embedded">
<a name="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">In Python</h5>
</div>
  <div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
    myDoc.ClearAll("SheetX.A1:F10")
    myDoc.ClearAll("SheetX.A1:J10", "=SheetX.A1&gt;100", "CELL")
    myDoc.ClearAll("SheetX.A1:J10", "=SUM(SheetX.A1:J1)&gt;100", "ROW")
    myDoc.ClearAll("SheetX.A1:J10", "=SUM(SheetX.A1:A10)&gt;100", "COLUMN")
  </code></pre></div>


<a name="ClearFormats"></a>
  
  <a name="bm_id591592919864362"></a>
      <meta itemprop="keywords" content="Calc service,ClearFormats">
  
  <h2 id="hd_id871592919864356" dir="auto">ClearFormats</h2>
  <p id="par_id211592919864118" class="paragraph" dir="auto">Clears the formats and styles in the given range.</p>
  <p id="par_id961670941800058" class="paragraph" dir="auto">A filter formula can be specified to determine which cells shall be affected.</p>
  <div class="embedded">
<a name="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Syntax:</h3>
</div>
  <p id="par_id381621536397094" class="paragraph" dir="auto">
    <span class="input" data-tooltip="Click on text to copy to clipboard">svc.ClearFormats(range: str, opt filterformula: str, opt filterscope: str)</span>
  </p>
  <div class="embedded">
<a name="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parameters:</h3>
</div>
  <p id="par_id611592919864268" class="paragraph" dir="auto"><span class="emph">range</span>: The range whose formats and styles are to be cleared, as a string.</p>
  <div class="embedded">
<a name="filterformula_desc"></a>
    <p id="par_id351670939954166" class="paragraph" dir="auto"><span class="emph">filterformula:</span> A Calc formula that shall be applied to the given range to determine which cells will be affected. The specified formula must return <span class="literal">True</span> or <span class="literal">False</span>. If this argument is not specified, then all cells in the range are affected.</p>
    <p id="par_id461670939954392" class="paragraph" dir="auto"><span class="emph">filterscope:</span> Determines how <span class="literal">filterformula</span> is expanded to the given range. This argument is mandatory if a <span class="literal">filterformula</span> is specified. The following values are accepted:</p>
    <ul itemprop="Unordered" itemscope="true" itemtype="http://schema.org/ItemList" dir="auto">
      <li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
        <p id="par_id991670941074213" class="listitem" dir="auto"><span class="emph">"CELL":</span> The formula specified in the <span class="literal">filterformula</span> argument is expanded once for each cell in <span class="literal">range</span>.</p>
      </li>
      <li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
        <p id="par_id911670941074926" class="listitem" dir="auto"><span class="emph">"ROW":</span> The formula specified in the <span class="literal">filterformula</span> argument is expanded once for each row in <span class="literal">range</span>.</p>
      </li>
      <li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
        <p id="par_id581670941075101" class="listitem" dir="auto"><span class="emph">"COLUMN":</span> The formula specified in the <span class="literal">filterformula</span> argument is expanded once for each column in <span class="literal">range</span>.</p>
      </li>
    </ul>
  </div>
  <div class="embedded">
<a name="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Example:</h3>
</div>
  <div class="embedded">
<a name="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">In Basic</h5>
</div>
  <div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
      oDoc.ClearFormats("SheetX.*")
  </code></pre></div>
  <div class="embedded">
<a name="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">In Python</h5>
</div>
  <div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
    myDoc.ClearFormats("SheetX.*")
  </code></pre></div>
  <div class="tip">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/tip.svg" alt="tip" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id461670942481018" dir="auto">Refer to the <a target="_top" href="en-US/text/sbasic/shared/03/sf_calc.html#ClearAll"><span class="literal">ClearAll</span></a> method documentation for examples on how to use the arguments <span class="literal">filterformula</span> and <span class="literal">filterscope</span>.</p></div>
</div>
<br>


<a name="ClearValues"></a>
  
  <a name="bm_id781592919928644"></a>
      <meta itemprop="keywords" content="Calc service,ClearValues">
  
  <h2 id="hd_id111592919928265" dir="auto">ClearValues</h2>
  <p id="par_id841592919928169" class="paragraph" dir="auto">Clears the values and formulas in the given range.</p>
  <p id="par_id961670941801218" class="paragraph" dir="auto">A filter formula can be specified to determine which cells shall be affected.</p>
  <div class="embedded">
<a name="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Syntax:</h3>
</div>
  <p id="par_id951621536609302" class="paragraph" dir="auto">
    <span class="input" data-tooltip="Click on text to copy to clipboard">svc.ClearValues(range: str, opt filterformula: str, opt filterscope: str)</span>
  </p>
  <div class="embedded">
<a name="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parameters:</h3>
</div>
  <p id="par_id771592919928320" class="paragraph" dir="auto"><span class="emph">range</span>: The range whose values and formulas are to be cleared, as a string.</p>
  <div class="embedded">
<a name="filterformula_desc"></a>
    <p id="par_id351670939954166" class="paragraph" dir="auto"><span class="emph">filterformula:</span> A Calc formula that shall be applied to the given range to determine which cells will be affected. The specified formula must return <span class="literal">True</span> or <span class="literal">False</span>. If this argument is not specified, then all cells in the range are affected.</p>
    <p id="par_id461670939954392" class="paragraph" dir="auto"><span class="emph">filterscope:</span> Determines how <span class="literal">filterformula</span> is expanded to the given range. This argument is mandatory if a <span class="literal">filterformula</span> is specified. The following values are accepted:</p>
    <ul itemprop="Unordered" itemscope="true" itemtype="http://schema.org/ItemList" dir="auto">
      <li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
        <p id="par_id991670941074213" class="listitem" dir="auto"><span class="emph">"CELL":</span> The formula specified in the <span class="literal">filterformula</span> argument is expanded once for each cell in <span class="literal">range</span>.</p>
      </li>
      <li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
        <p id="par_id911670941074926" class="listitem" dir="auto"><span class="emph">"ROW":</span> The formula specified in the <span class="literal">filterformula</span> argument is expanded once for each row in <span class="literal">range</span>.</p>
      </li>
      <li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
        <p id="par_id581670941075101" class="listitem" dir="auto"><span class="emph">"COLUMN":</span> The formula specified in the <span class="literal">filterformula</span> argument is expanded once for each column in <span class="literal">range</span>.</p>
      </li>
    </ul>
  </div>
  <div class="embedded">
<a name="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Example:</h3>
</div>
  <div class="embedded">
<a name="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">In Basic</h5>
</div>
  <div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
      oDoc.ClearValues("SheetX.A1:F10")
  </code></pre></div>
  <div class="embedded">
<a name="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">In Python</h5>
</div>
  <div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
    myDoc.ClearValues("SheetX.A1:F10")
  </code></pre></div>
  <div class="tip">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/tip.svg" alt="tip" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id461670942483664" dir="auto">Refer to the <a target="_top" href="en-US/text/sbasic/shared/03/sf_calc.html#ClearAll"><span class="literal">ClearAll</span></a> method documentation for examples on how to use the arguments <span class="literal">filterformula</span> and <span class="literal">filterscope</span>.</p></div>
</div>
<br>


<a name="CompactLeft"></a>
  
  <a name="bm_id781592919922589"></a>
    <meta itemprop="keywords" content="Calc service,CompactLeft">
  
  <h2 id="hd_id111592919923294" dir="auto">CompactLeft</h2>
  <p id="par_id841592919903025" class="paragraph" dir="auto">Deletes the columns of a specified range that match a filter expressed as a Calc formula. The filter is applied to each column to decide whether it will be deleted or not.</p>
  <p id="par_id601652269911029" class="paragraph" dir="auto">The deleted column can be limited to the height of the specified range or span to the height of the entire sheet, thus deleting whole columns.</p>
  <p id="par_id701652271281106" class="paragraph" dir="auto">This method returns a string with the range address of the compacted range. If all columns are deleted, then an empty string is returned.</p>
  <div class="note">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/note.svg" alt="note" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id191652271892064" dir="auto">If a range of cells is selected, calling this method will not impact the selection.</p></div>
</div>
<br>
  <div class="embedded">
<a name="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Syntax:</h3>
</div>
  <p id="par_id951621536600632" class="paragraph" dir="auto">
    <span class="input" data-tooltip="Click on text to copy to clipboard">svc.CompactLeft(range: str, wholecolumn: bool = False, opt filterformula: str): str</span>
  </p>
  <div class="embedded">
<a name="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parameters:</h3>
</div>
  <p id="par_id771592919922181" class="paragraph" dir="auto"><span class="emph">range</span>: The range from which columns will be deleted, as a string.</p>
  <p id="par_id771592919932260" class="paragraph" dir="auto"><span class="emph">wholecolumn</span>: If this option is set to <span class="literal">True</span> the entire column will be deleted from the sheet. The default value is <span class="literal">False</span>, which means that the deleted column will be limited to the height of the specified <span class="literal">range</span>.</p>
  <p id="par_id771592919915974" class="paragraph" dir="auto"><span class="emph">filterformula</span>: The filter to be applied to each column to determine whether or not it will be deleted. The filter is expressed as a Calc formula that should be applied to the first column. When the formula returns <span class="emph">True</span> for a column, that column will be deleted. The default filter deletes all empty columns.</p>
  <p id="par_id361652271022647" class="paragraph" dir="auto">For example, suppose range <span class="emph">A1:J200</span> is selected (height = 200), so the default formula is <span class="emph">=(COUNTBLANK(A1:A200)=200)</span>. This means that if all 200 cells are empty in the first column (Column A), then the column is deleted. Note that the formula is expressed with respect to the first column only. Internally the <span class="literal">CompactLeft</span> method will generalize this formula for all the remaining columns.</p>
  <div class="note">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/note.svg" alt="note" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id431657568414625" dir="auto">Calc functions used in the <span class="literal">filterformula</span> argument must be expressed using their English names. Visit the Wiki page <a target="_blank" href="https://wiki.documentfoundation.org/Documentation/Calc_Functions/List_of_Functions">List of Calc Functions</a> for a complete list of Calc functions in English.</p></div>
</div>
<br>
  <div class="embedded">
<a name="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Example:</h3>
</div>
  <div class="embedded">
<a name="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">In Basic</h5>
</div>
  <div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
    ' Delete all empty columns in the range G1:L10 from Sheet1
    newrange = oDoc.CompactLeft("Sheet1.G1:L10")
    ' The example below is similar, but the entire column is deleted from the sheet
    newrange = oDoc.CompactLeft("Sheet1.G1:L10", WholeColumn := True)
    ' Deletes all columns where the first row is marked with an "X"
    newrange = oDoc.CompactLeft("Sheet1.G1:L10", FilterFormula := "=(G1=""X"")")
    ' Deletes all columns where the sum of values in the column is odd
    newrange = oDoc.CompactLeft("Sheet1.G1:L10", FilterFormula := "=(MOD(SUM(G1:G10);2)=1)")
  </code></pre></div>
  <div class="embedded">
<a name="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">In Python</h5>
</div>
  <div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
    newrange = myDoc.CompactLeft("Sheet1.G1:L10")
    newrange = myDoc.CompactLeft("Sheet1.G1:L10", wholecolumn = True)
    newrange = myDoc.CompactLeft("Sheet1.G1:L10", filterformula = '=(G1="X")')
    newrange = myDoc.CompactLeft("Sheet1.G1:L10", filterformula = '=(MOD(SUM(G1:G10);2)=1)')
  </code></pre></div>


<a name="CompactUp"></a>
  
  <a name="bm_id781592919928589"></a>
    <meta itemprop="keywords" content="Calc service,CompactUp">
  
  <h2 id="hd_id111592919923065" dir="auto">CompactUp</h2>
  <p id="par_id841592919903699" class="paragraph" dir="auto">Deletes the rows of a specified range that match a filter expressed as a Calc formula. The filter is applied to each row to decide whether it will be deleted or not.</p>
  <p id="par_id601652269910091" class="paragraph" dir="auto">The deleted rows can be limited to the width of the specified range or span to the width of the entire sheet, thus deleting whole rows.</p>
  <p id="par_id701652271283456" class="paragraph" dir="auto">This method returns a string with the range address of the compacted range. If all rows are deleted, then an empty string is returned.</p>
  <div class="note">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/note.svg" alt="note" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id191652271893913" dir="auto">If a range of cells is selected, calling this method will not impact the selection.</p></div>
</div>
<br>
  <div class="embedded">
<a name="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Syntax:</h3>
</div>
  <p id="par_id951621536605642" class="paragraph" dir="auto">
    <span class="input" data-tooltip="Click on text to copy to clipboard">svc.CompactUp(range: str, wholerow: bool = False, opt filterformula: str): str</span>
  </p>
  <div class="embedded">
<a name="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parameters:</h3>
</div>
  <p id="par_id771592919922080" class="paragraph" dir="auto"><span class="emph">range</span>: The range from which rows will be deleted, as a string.</p>
  <p id="par_id771592919921160" class="paragraph" dir="auto"><span class="emph">wholerow</span>: If this option is set to <span class="literal">True</span> the entire row will be deleted from the sheet. The default value is <span class="literal">False</span>, which means that the deleted row will be limited to the width of the specified <span class="literal">range</span>.</p>
  <p id="par_id771592919926374" class="paragraph" dir="auto"><span class="emph">filterformula</span>: The filter to be applied to each row to determine whether or not it will be deleted. The filter is expressed as a Calc formula that should be applied to the first row. When the formula returns <span class="emph">True</span> for a row, that row will be deleted. The default filter deletes all empty rows.</p>
  <p id="par_id361652271022681" class="paragraph" dir="auto">For example, suppose range <span class="emph">A1:J200</span> is selected (width = 10), so the default formula is <span class="emph">=(COUNTBLANK(A1:J1)=10)</span>. This means that if all 10 cells are empty in the first row (Row 1), then the row is deleted. Note that the formula is expressed with respect to the first row only. Internally the <span class="literal">CompactUp</span> method will generalize this formula for all the remaining rows.</p>
  <div class="note">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/note.svg" alt="note" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id431657568414714" dir="auto">The Calc functions used in the formula specified in the <span class="literal">filterformula</span> argument must be expressed using their English names. Visit the Wiki page <a target="_blank" href="https://wiki.documentfoundation.org/Documentation/Calc_Functions/List_of_Functions">List of Calc Functions</a> for a complete list of Calc functions in English.</p></div>
</div>
<br>
  <div class="embedded">
<a name="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Example:</h3>
</div>
  <div class="embedded">
<a name="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">In Basic</h5>
</div>
  <div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
    ' Delete all empty rows in the range G1:L10 from Sheet1
    newrange = oDoc.CompactUp("Sheet1.G1:L10")
    ' The example below is similar, but the entire row is deleted from the sheet
    newrange = oDoc.CompactUp("Sheet1.G1:L10", WholeRow := True)
    ' Deletes all rows where the first column is marked with an "X"
    newrange = oDoc.CompactUp("Sheet1.G1:L10", FilterFormula := "=(G1=""X"")")
    ' Deletes all rows where the sum of values in the row is odd
    newrange = oDoc.CompactUp("Sheet1.G1:L10", FilterFormula := "=(MOD(SUM(G1:L1);2)=1)")
  </code></pre></div>
  <div class="embedded">
<a name="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">In Python</h5>
</div>
  <div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
    newrange = myDoc.CompactUp("Sheet1.G1:L10")
    newrange = myDoc.CompactUp("Sheet1.G1:L10", wholerow = True)
    newrange = myDoc.CompactUp("Sheet1.G1:L10", filterformula = '=(G1="X")')
    newrange = myDoc.CompactUp("Sheet1.G1:L10", filterformula = '=(MOD(SUM(G1:L1);2)=1)')
  </code></pre></div>


<a name="CopySheet"></a>
  
  <a name="bm_id901591631693213"></a>
      <meta itemprop="keywords" content="Calc service,CopySheet">
  
  <h2 id="hd_id51591631693461" dir="auto">CopySheet</h2>
  <p id="par_id591591631693816" class="paragraph" dir="auto">Copies a specified sheet before an existing sheet or at the end of the list of sheets. The sheet to be copied may be contained inside any <span class="emph">open</span> Calc document. Returns <span class="literal">True</span> if successful.</p>
  <div class="embedded">
<a name="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Syntax:</h3>
</div>
  <p id="par_id411621536777187" class="paragraph" dir="auto">
    <span class="input" data-tooltip="Click on text to copy to clipboard">svc.CopySheet(sheetname: any, newname: str, [beforesheet: any]): bool</span>
  </p>
  <div class="embedded">
<a name="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parameters:</h3>
</div>
  <p id="par_id871591631693741" class="paragraph" dir="auto"><span class="emph">sheetname</span>: The name of the sheet to be copied as a string or its reference as an object.</p>
  <p id="par_id351591632126180" class="paragraph" dir="auto"><span class="emph">newname</span>: The name of the sheet to insert. The name must not be in use in the document.</p>
  <p id="par_id211591632192379" class="paragraph" dir="auto"><span class="emph">beforesheet</span>: The name (string) or index (numeric, starting from 1) of the sheet before which to insert the copied sheet. This argument is optional and the default behavior is to add the copied sheet at the last position.</p>
  <div class="embedded">
<a name="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Example:</h3>
</div>
  <div class="embedded">
<a name="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">In Basic</h5>
</div>
  <p id="par_id961591632309410" class="paragraph" dir="auto">The following example makes a copy of the sheet "SheetX" and places it as the last sheet in the current document. The name of the copied sheet is "SheetY".</p>
  <div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
    Dim oDoc as Object
    'Gets the Document object of the active window
    Set oDoc = CreateScriptService("Calc")
    oDoc.CopySheet("SheetX", "SheetY")
  </code></pre></div>
  <p id="par_id461591632297415" class="paragraph" dir="auto">The example below copies "SheetX" from "FileA.ods" and pastes it at the last position of "FileB.ods" with the name "SheetY":</p>
  <div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
      Dim oDocA As Object : Set oDocA = ui.OpenDocument("C:\Documents\FileA.ods", Hidden := True, ReadOnly := True)
      Dim oDocB As Object : Set oDocB = ui.OpenDocument("C:\Documents\FileB.ods")
      oDocB.CopySheet(oDocA.Sheet("SheetX"), "SheetY")
  </code></pre></div>
  <div class="embedded">
<a name="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">In Python</h5>
</div>
  <div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
    myDoc.CopySheet("SheetX", "SheetY")
  </code></pre></div>
  <div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
    docA = ui.OpenDocument(r"C:\Documents\FileA.ods", hidden = True, readonly = True)
    docB = ui.OpenDocument(r"C:\Documents\FileB.ods")
    docB.CopySheet(docA.Sheet("SheetX"), "SheetY")
  </code></pre></div>
  <div class="tip">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/tip.svg" alt="tip" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id801595695285478" dir="auto">To copy sheets between <span class="emph">open</span> documents, use <span class="literal">CopySheet</span>. To copy sheets from documents that are <span class="emph">closed</span>, use <span class="literal">CopySheetFromFile</span>.</p></div>
</div>
<br>


<a name="CopySheetFromFile"></a>
  
  <a name="bm_id101591714614827"></a>
      <meta itemprop="keywords" content="Calc service,CopySheetFromFile">
  
  <h2 id="hd_id301591714614286" dir="auto">CopySheetFromFile</h2>
    <p id="par_id931591714614755" class="paragraph" dir="auto">Copies a specified sheet from a <span class="emph">closed</span> Calc document and pastes it before an existing sheet or at the end of the list of sheets of the file referred to by a <span class="literal">Document</span> object.</p>
    <p id="par_id271611706609445" class="paragraph" dir="auto">If the file does not exist, an error is raised. If the file is not a valid Calc file, a blank sheet is inserted. If the source sheet does not exist in the input file, an error message is inserted at the top of the newly pasted sheet.</p>
  <div class="embedded">
<a name="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Syntax:</h3>
</div>
  <p id="par_id721621537513995" class="paragraph" dir="auto">
    <span class="input" data-tooltip="Click on text to copy to clipboard">svc.CopySheetFromFile(filename: str, sheetname: str, newname: str, [beforesheet: any]): bool</span>
  </p>
  <div class="embedded">
<a name="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parameters:</h3>
</div>
  <p id="par_id471591714947181" class="paragraph" dir="auto"><span class="emph">filename</span>: Identifies the file to open. It must follow the <span class="literal">SF_FileSystem.FileNaming</span> notation. The file must not be protected with a password.</p>
  <p id="par_id9915917146142" class="paragraph" dir="auto"><span class="emph">sheetname</span>: The name of the sheet to be copied as a string.</p>
  <p id="par_id71591714614904" class="paragraph" dir="auto"><span class="emph">newname</span>: The name of the copied sheet to be inserted in the document. The name must not be in use in the document.</p>
  <p id="par_id601591714614407" class="paragraph" dir="auto"><span class="emph">beforesheet</span>: The name (string) or index (numeric, starting from 1) of the sheet before which to insert the copied sheet. This argument is optional and the default behavior is to add the copied sheet at the last position.</p>
  <div class="embedded">
<a name="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Example:</h3>
</div>
  <p id="par_id981611707192039" class="paragraph" dir="auto">The following example copies "SheetX" from "myFile.ods" and pastes it into the document referred to by "oDoc" as "SheetY" at the first position.</p>
  <div class="embedded">
<a name="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">In Basic</h5>
</div>
  <div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
    oDoc.CopySheetFromFile("C:\Documents\myFile.ods", "SheetX", "SheetY", 1)
  </code></pre></div>
  <div class="embedded">
<a name="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">In Python</h5>
</div>
  <div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
    myDoc.CopySheetFromFile(r"C:\Documents\myFile.ods", "SheetX", "SheetY", 1)
  </code></pre></div>


<a name="CopyToCell"></a>
  
  <a name="bm_id481592558768560"></a>
      <meta itemprop="keywords" content="Calc service,CopyToCell">
  
  <h2 id="hd_id261592558768660" dir="auto">CopyToCell</h2>
  <p id="par_id91592558768804" class="paragraph" dir="auto">Copies a specified source range (values, formulas and formats) to a destination range or cell. The method reproduces the behaviour of a Copy/Paste operation from a range to a single cell.</p>
  <p id="par_id831611707431984" class="paragraph" dir="auto">It returns a string representing the modified range of cells. The size of the modified area is fully determined by the size of the source area.</p>
  <p id="par_id681592558768463" class="paragraph" dir="auto">The source range may belong to another <span class="emph">open</span> document.</p>
  <div class="embedded">
<a name="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Syntax:</h3>
</div>
  <p id="par_id431621537972303" class="paragraph" dir="auto">
    <span class="input" data-tooltip="Click on text to copy to clipboard">svc.CopyToCell(sourcerange: any, destinationcell: str): str</span>
  </p>
  <div class="embedded">
<a name="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parameters:</h3>
</div>
  <p id="par_id761592558768578" class="paragraph" dir="auto"><span class="emph">sourcerange</span>: The source range as a string when it belongs to the same document or as a reference when it belongs to another open Calc document.</p>
  <p id="par_id711592558768466" class="paragraph" dir="auto"><span class="emph">destinationcell</span>: The destination cell where the copied range of cells will be pasted, as a string. If a range is given, only its top-left cell is considered.</p>
  <div class="embedded">
<a name="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Example:</h3>
</div>
  <div class="embedded">
<a name="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">In Basic</h5>
</div>
  <p id="par_id431592904964362" class="paragraph" dir="auto">Next is an example where the source and destination are in the same file:</p>
  <div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
      oDoc.CopyToCell("SheetX.A1:F10", "SheetY.C5")
  </code></pre></div>
  <p id="par_id751592905035452" class="paragraph" dir="auto">The example below illustrates how to copy a range from another open Calc document:</p>
  <div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
    Dim ui as Variant : ui = CreateScriptService("UI")
    Dim oDocSource As Object, oDocDestination As Object
    'Open the source document in the background (hidden)
    Set oDocSource = ui.OpenDocument("C:\SourceFile.ods", Hidden := True, ReadOnly := True)
    Set oDocDestination = CreateScriptService("Calc")
    oDocDestination.CopyToCell(oDocSource.Range("Sheet1.C2:C4"), "SheetT.A5")
    'Do not forget to close the source document because it was opened as hidden
    oDocSource.CloseDocument()
  </code></pre></div>
  <div class="embedded">
<a name="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">In Python</h5>
</div>
  <div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
    docSource = ui.OpenDocument(r"C:\Documents\SourceFile.ods", hidden = True, readonly = True)
    docDestination = CreateScriptService("Calc")
    docDestination.CopyToCell(docSource.Range("Sheet1.C2:C4"), "SheetT.A5")
    docSource.CloseDocument()
  </code></pre></div>
  <div class="tip">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/tip.svg" alt="tip" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id61592905442071" dir="auto">To simulate a Copy/Paste from a range to a single cell, use <span class="literal">CopyToCell</span>. To simulate a Copy/Paste from a range to a larger range (with the same cells being replicated several times), use <span class="literal">CopyToRange</span>.</p></div>
</div>
<br>


<a name="CopyToRange"></a>
  
  <a name="bm_id171592903121677"></a>
      <meta itemprop="keywords" content="Calc service,CopyToRange">
  
  <h2 id="hd_id67159290312183" dir="auto">CopyToRange</h2>
  <p id="par_id1615929031212" class="paragraph" dir="auto">Copies downwards and/or rightwards a specified source range (values, formulas and formats) to a destination range. The method imitates the behaviour of a Copy/Paste operation from a source range to a larger destination range.</p>
  <ul itemprop="Unordered" itemscope="true" itemtype="http://schema.org/ItemList" dir="auto">
      <li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
          <p id="par_id271592904084534" class="paragraph" dir="auto">If the height (or width) of the destination area is &gt; 1 row (or column) then the height (or width) of the source must be &lt;= the height (or width) of the destination. Otherwise nothing happens.</p>
      </li>
      <li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
          <p id="par_id131592904286834" class="paragraph" dir="auto">If the height (or width) of the destination is = 1 then the destination is expanded downwards (or rightwards) up to the height (or width) of the source range.</p>
      </li>
  </ul>
  <p id="par_id661592904348877" class="paragraph" dir="auto">The method returns a string representing the modified range of cells.</p>
  <p id="par_id41592903121807" class="paragraph" dir="auto">The source range may belong to another <span class="emph">open</span> document.</p>
  <div class="embedded">
<a name="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Syntax:</h3>
</div>
  <p id="par_id981621538491567" class="paragraph" dir="auto">
    <span class="input" data-tooltip="Click on text to copy to clipboard">svc.CopyToRange(sourcerange: any, destinationrange: str): str</span>
  </p>
  <div class="embedded">
<a name="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parameters:</h3>
</div>
  <p id="par_id841592903121145" class="paragraph" dir="auto"><span class="emph">sourcerange</span>: The source range as a string when it belongs to the same document or as a reference when it belongs to another open Calc document.</p>
  <p id="par_id5515929031211000" class="paragraph" dir="auto"><span class="emph">destinationrange</span>: The destination of the copied range of cells, as a string.</p>
  <div class="embedded">
<a name="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Example:</h3>
</div>
  <div class="embedded">
<a name="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">In Basic</h5>
</div>
  <p id="par_id461592905128991" class="paragraph" dir="auto">Copy within the same document:</p>
  <div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
    oDoc.CopyToRange("SheetX.A1:F10", "SheetY.C5:J5")
    ' Returns a range string: "$SheetY.$C$5:$J$14"
  </code></pre></div>
  <p id="par_id1001592905195364" class="paragraph" dir="auto">Copy from one file to another:</p>
  <div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
    Dim oDocA As Object : Set oDocA = ui.OpenDocument("C:\Documents\FileA.ods", Hidden := True, ReadOnly := True)
    Dim oDocB As Object : Set oDocB = ui.OpenDocument("C:\Documents\FileB.ods")
    oDocB.CopyToRange(oDocA.Range("SheetX.A1:F10"), "SheetY.C5:J5")
  </code></pre></div>
  <div class="embedded">
<a name="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">In Python</h5>
</div>
  <div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
    doc.CopyToRange("SheetX.A1:F10", "SheetY.C5:J5")
  </code></pre></div>
  <div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
    docA = ui.OpenDocument(r"C:\Documents\FileA.ods", hidden = True, readonly = True)
    docB = ui.OpenDocument(r"C:\Documents\FileB.ods")
    docB.CopyToRange(docA.Range("SheetX.A1:F10"), "SheetY.C5:J5")
  </code></pre></div>


<a name="CreateChart"></a>
  
  <a name="bm_id171592903123257"></a>
      <meta itemprop="keywords" content="Calc service,CreateChart">
  
  <h2 id="hd_id67159290312287" dir="auto">CreateChart</h2>
  <p id="par_id1615929033642" class="paragraph" dir="auto">Creates a new chart object showing the data in the specified range. The returned chart object can be further manipulated using the <span class="literal">Chart</span> service.</p>
  <div class="embedded">
<a name="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Syntax:</h3>
</div>
  <p id="par_id981621538499667" class="paragraph" dir="auto">
    <span class="input" data-tooltip="Click on text to copy to clipboard">svc.CreateChart(chartname: str, sheetname: str, range: str, columnheader: bool = False, rowheader: bool = False): obj</span>
  </p>
  <div class="embedded">
<a name="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parameters:</h3>
</div>
  <p id="par_id841592903121025" class="paragraph" dir="auto"><span class="emph">chartname:</span> The user-defined name of the chart to be created. The name must be unique in the same sheet.</p>
  <p id="par_id5515929031213680" class="paragraph" dir="auto"><span class="emph">sheetname:</span> The name of the sheet where the chart will be placed.</p>
  <p id="par_id5515929031211522" class="paragraph" dir="auto"><span class="emph">range:</span> The range to be used as the data source for the chart. The range may refer to any sheet of the Calc document.</p>
  <p id="par_id5515929031216390" class="paragraph" dir="auto"><span class="emph">columnheader:</span> When <span class="literal">True</span>, the topmost row of the range is used as labels for the category axis or the legend (Default = <span class="literal">False</span>).</p>
  <p id="par_id5515929031211633" class="paragraph" dir="auto"><span class="emph">rowheader:</span> When <span class="literal">True</span>, the leftmost column of the range is used as labels for the category axis or the legend. (Default = <span class="literal">False</span>).</p>
  <div class="embedded">
<a name="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Example:</h3>
</div>
  <p id="par_id61635441176547" class="paragraph" dir="auto">The examples below in Basic and Python create a chart using the data contained in the range "A1:B5" of "Sheet1" and place the chart in "Sheet2".</p>
  <div class="embedded">
<a name="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">In Basic</h5>
</div>
  <div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
    Set oChart = oDoc.CreateChart("MyChart", "Sheet2", "Sheet1.A1:B5", RowHeader := True)
    oChart.ChartType = "Donut"
  </code></pre></div>
  <div class="embedded">
<a name="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">In Python</h5>
</div>
  <div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
    chart = doc.CreateChart("MyChart", "Sheet2", "Sheet1.A1:B5", rowheader=True)
    chart.ChartType = "Donut"
  </code></pre></div>
  <div class="tip">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/tip.svg" alt="tip" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id231635441342180" dir="auto">Refer to the help page about ScriptForge's <a target="_top" href="en-US/text/sbasic/shared/03/sf_chart.html">Chart service</a> to learn more how to further manipulate chart objects. It is possible to change properties as the chart type, chart and axes titles and chart position.</p></div>
</div>
<br>


<a name="CreatePivotTable"></a>
  
  <a name="bm_id171592903120147"></a>
      <meta itemprop="keywords" content="Calc service,CreatePivotTable">
  
  <h2 id="hd_id67159290319647" dir="auto">CreatePivotTable</h2>
  <p id="par_id1615929033065" class="paragraph" dir="auto">Creates a new pivot table with the properties defined by the arguments  passed to the method.</p>
  <p id="par_id1001652794922144" class="paragraph" dir="auto">A name must be provided for the pivot table. If a pivot table with the same name already exists in the targeted sheet, it will be replaced without warning.</p>
  <p id="par_id751652795324382" class="paragraph" dir="auto">This method returns a string containing the range where the new pivot table was placed.</p>
  <div class="embedded">
<a name="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Syntax:</h3>
</div>
  <p id="par_id981621538467457" class="paragraph" dir="auto">
    <span class="input" data-tooltip="Click on text to copy to clipboard">svc.CreatePivotTable(pivottablename: str, sourcerange: str, targetcell: str, datafields: str[0..*], rowfields: str[0..*], columnfields: str[0..*], filterbutton: bool = true, rowtotals: bool = true, columntotals: bool = true): str</span>
  </p>
  <div class="embedded">
<a name="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parameters:</h3>
</div>
  <p id="par_id841592903128525" class="paragraph" dir="auto"><span class="emph">pivottablename:</span> The user-defined name of the new pivot table.</p>
  <p id="par_id5515929031203640" class="paragraph" dir="auto"><span class="emph">sourcerange:</span> The range containing the raw data, as a string. It is assumed that the first row contains the field names that are used by the pivot table.</p>
  <p id="par_id5515929031210400" class="paragraph" dir="auto"><span class="emph">targetcell:</span> The top-left cell where the new pivot table will be placed. If a range is specified, only its top-left cell is considered.</p>
  <p id="par_id5515929031951290" class="paragraph" dir="auto"><span class="emph">datafields:</span> It can be either a single string or an array containing strings that define field names and functions to be applied. When an array is specified, it must follow the syntax <span class="input" data-tooltip="Click on text to copy to clipboard">Array("FieldName[;Function]", ...)</span>.</p>
  <p id="par_id361652795942348" class="paragraph" dir="auto">The allowed functions are: <span class="literal">Sum</span>, <span class="literal">Count</span>, <span class="literal">Average</span>, <span class="literal">Max</span>, <span class="literal">Min</span>, <span class="literal">Product</span>, <span class="literal">CountNums</span>, <span class="literal">StDev</span>, <span class="literal">StDevP</span>, <span class="literal">Var</span>, <span class="literal">VarP</span> and <span class="literal">Median</span>. Function names must be provided in English. When all values are numerical, <span class="literal">Sum</span> is the default function, otherwise the default function is <span class="literal">Count</span>.</p>
  <p id="par_id5515929031211003" class="paragraph" dir="auto"><span class="emph">rowfields:</span> A single string or an array with the field names that will be used as the pivot table rows.</p>
  <p id="par_id5515929031211114" class="paragraph" dir="auto"><span class="emph">columnfields:</span> A single string or an array with the field names that will be used as the pivot table columns.</p>
  <p id="par_id361652796141240" class="paragraph" dir="auto"><span class="emph">filterbutton:</span> Determines whether a filter button will be displayed above the pivot table (Default = <span class="literal">True</span>).</p>
  <p id="par_id661652796200051" class="paragraph" dir="auto"><span class="emph">rowtotals:</span> Specifies if a separate column for row totals will be added to the pivot table (Default = <span class="literal">True</span>).</p>
  <p id="par_id671652796274304" class="paragraph" dir="auto"><span class="emph">columntotals</span> Specifies if a separate row for column totals will be added to the pivot table (Default = <span class="literal">True</span>)</p>
  <div class="embedded">
<a name="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Example:</h3>
</div>
  <div class="embedded">
<a name="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">In Basic</h5>
</div>
  <div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
    Dim vData As Variant, oDoc As Object, ui As Object, sTable As String, sPivot As String
    Set ui = CreateScriptService("UI")
    Set oDoc = ui.CreateDocument("Calc")
    vData = Array(Array("Item", "State", "Team", "2002", "2003", "2004"), _
        Array("Books", "Michigan", "Jean", 14788, 30222, 23490), _
        Array("Candy", "Michigan", "Jean", 26388, 15641, 32849), _
        Array("Pens", "Michigan", "Jean", 16569, 32675, 25396), _
        Array("Books", "Michigan", "Volker", 21961, 21242, 29009), _
        Array("Candy", "Michigan", "Volker", 26142, 22407, 32841))
    sTable = oDoc.SetArray("A1", vData)
    sPivot = oDoc.CreatePivotTable("PT1", sTable, "H1", _
        Array("2002", "2003;count", "2004;average"), _ ' Three data fields
        "Item", _ ' A single row field
        Array("State", "Team"), False) ' Two column fields
  </code></pre></div>
  <div class="embedded">
<a name="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">In Python</h5>
</div>
  <div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
    ui = CreateScriptService("UI")
    doc = ui.CreateDocument("Calc")
    vData = [["Item", "State", "Team", "2002", "2003", "2004"],
             ["Books", "Michigan", "Jean", 14788, 30222, 23490],
             ["Candy", "Michigan", "Jean", 26388, 15641, 32849],
             ["Pens", "Michigan", "Jean", 16569, 32675, 25396)],
             ["Books", "Michigan", "Volker", 21961, 21242, 29009],
             ["Candy", "Michigan", "Volker", 26142, 22407, 32841]]
    sTable = doc.SetArray("A1", vData)
    sPivot = doc.CreatePivotTable("PT1", sTable, "H1",
                                  ["2002", "2003;count", "2004;average"],
                                  "Item",
                                  ["State", "Team"], False)
  </code></pre></div>
  <div class="tip">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/tip.svg" alt="tip" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id231635441342284" dir="auto">To learn more about Pivot Tables in LibreOffice Calc, read the <a target="_top" href="en-US/text/scalc/guide/datapilot.html">Pivot Table</a> help page.</p></div>
</div>
<br>



<a name="DAvg"></a>
  
  <a name="bm_id791595777001863"></a>
      <meta itemprop="keywords" content="Calc service,DAvg">
      <meta itemprop="keywords" content="Calc service,DCount">
      <meta itemprop="keywords" content="Calc service,DMax">
      <meta itemprop="keywords" content="Calc service,DMin">
      <meta itemprop="keywords" content="Calc service,DSum">
  
  <h2 id="hd_id471595777001777" dir="auto">DAvg, DCount, DMax, DMin and DSum</h2>
  <p id="par_id601595777001498" class="paragraph" dir="auto">Apply the functions Average, Count, Max, Min and Sum, respectively, to all the cells containing numeric values on a given range, excluding values from filtered and hidden rows and hidden columns, the same as for the status bar functions.</p>
  <div class="embedded">
<a name="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Syntax:</h3>
</div>
  <p id="par_id471621539319385" class="paragraph" dir="auto">
    <span class="input" data-tooltip="Click on text to copy to clipboard">svc.DAvg(range: str): float</span>
  </p>
  <p id="bas_id331595777279484" class="paragraph" dir="auto">
    <span class="input" data-tooltip="Click on text to copy to clipboard">svc.DCount(range: str): float</span>
  </p>
  <p id="bas_id911595777285935" class="paragraph" dir="auto">
    <span class="input" data-tooltip="Click on text to copy to clipboard">svc.DMax(range: str): float</span>
  </p>
  <p id="bas_id471595777292407" class="paragraph" dir="auto">
    <span class="input" data-tooltip="Click on text to copy to clipboard">svc.DMin(range: str): float</span>
  </p>
  <p id="bas_id41595777298840" class="paragraph" dir="auto">
    <span class="input" data-tooltip="Click on text to copy to clipboard">svc.DSum(range: str): float</span>
  </p>
  <div class="embedded">
<a name="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parameters:</h3>
</div>
  <p id="par_id741595777001537" class="paragraph" dir="auto"><span class="emph">range</span>: The range to which the function will be applied, as a string.</p>
  <div class="embedded">
<a name="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Example:</h3>
</div>
  <p id="par_id121611752704572" class="paragraph" dir="auto">The example below applies the <span class="literal">Sum</span> function to the range "A1:A1000" of the currently selected sheet:</p>
  <div class="embedded">
<a name="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">In Basic</h5>
</div>
  <div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
      result = oDoc.DSum("~.A1:A1000")
  </code></pre></div>
  <div class="embedded">
<a name="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">In Python</h5>
</div>
  <div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
    result = myDoc.DSum("~.A1:A1000")
  </code></pre></div>
  <div class="note">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/note.svg" alt="note" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id31611752782288" dir="auto">Cells in the given range that contain text will be ignored by all of these functions. For example, the <span class="literal">DCount</span> method will not count cells with text, only numerical cells.</p></div>
</div>
<br>


<a name="ExportRangeToFile"></a>
  
  <a name="bm_id271591632729478"></a>
      <meta itemprop="keywords" content="Calc service,ExportRangeToFile">
  
  <h2 id="hd_id331591632723258" dir="auto">ExportRangeToFile</h2>
  <p id="par_id501623063693113" class="paragraph" dir="auto">Exports the specified range as an image or PDF file.</p>
  <p id="par_id401655654738754" class="paragraph" dir="auto">This method returns <span class="literal">True</span> if the destination file was successfully saved.</p>
  <div class="note">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/note.svg" alt="note" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id871655655302952" dir="auto">Hidden rows or columns in the specified range are not exported to the destination file.</p></div>
</div>
<br>
  <div class="embedded">
<a name="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Syntax:</h3>
</div>
  <p id="par_id371623063577228" class="paragraph" dir="auto">
    <span class="input" data-tooltip="Click on text to copy to clipboard">svc.ExportRangeToFile(range: str, filename: str, imagetype: str = "pdf", overwrite: bool = False): bool</span>
  </p>
  <div class="embedded">
<a name="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parameters:</h3>
</div>
  <p id="par_id441623090896470" class="paragraph" dir="auto"><span class="emph">range</span>: A sheet name or a cell range to be exported, as a string.</p>
  <p id="par_id451623063452651" class="paragraph" dir="auto"><span class="emph">filename</span>: The name of the file to be saved. It must follow the <span class="literal">SF_FileSystem.FileNaming</span> notation.</p>
  <p id="par_id441623090895310" class="paragraph" dir="auto"><span class="emph">imagetype</span>: Identifies the destination file type. Possible values are "jpeg", "pdf" (default) and "png".</p>
  <p id="par_id441623090896317" class="paragraph" dir="auto"><span class="emph">overwrite</span>: When set to <span class="literal">True</span>, the destination file may be overwritten (Default = <span class="literal">False</span>).</p>
  <div class="embedded">
<a name="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Example:</h3>
</div>
  <div class="embedded">
<a name="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">In Basic</h5>
</div>
  <div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
    ' Exports the entire sheet as a PDF file
    oDoc.ExportRangeToFile("SheetX", "C:\Temp\image.pdf")
    ' Exports the range as a PNG file and overwrites the destination file if it exists
    oDoc.ExportRangeToFile("SheetX.A1:D10", "C:\Temp\image.png", "png", Overwrite := True)
  </code></pre></div>
  <div class="embedded">
<a name="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">In Python</h5>
</div>
  <div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
    doc.ExportRangeToFile("SheetX", r"C:\Temp\image.pdf")
    doc.ExportRangeToFile("SheetX.A1:D10", r"C:\Temp\image.png", "png", overwrite = True)
  </code></pre></div>


<a name="Forms"></a>
  
  <a name="bm_id271591632726788"></a>
      <meta itemprop="keywords" content="Calc service,Forms">
  
  <h2 id="hd_id331591632724120" dir="auto">Forms</h2>
  <p id="par_id501623063693649" class="paragraph" dir="auto">Depending on the parameters provided this method will return:</p>
  <ul itemprop="Unordered" itemscope="true" itemtype="http://schema.org/ItemList" dir="auto">
    <li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
        <p id="par_id611623063742045" class="listitem" dir="auto">A zero-based Array (or a tuple in Python) with the names of all the forms contained in a given sheet (if the <span class="literal">form</span> argument is absent)</p>
    </li>
    <li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
        <p id="par_id641623063744536" class="listitem" dir="auto">A <span class="literal">SFDocuments.Form</span> service instance representing the form specified as argument.</p>
    </li>
  </ul>
  <div class="embedded">
<a name="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Syntax:</h3>
</div>
  <p id="par_id371623063588128" class="paragraph" dir="auto">
    <span class="input" data-tooltip="Click on text to copy to clipboard">svc.Forms(sheetname: str): str[0..*]</span>
  </p>
  <p id="par_id371623063588699" class="paragraph" dir="auto">
    <span class="input" data-tooltip="Click on text to copy to clipboard">svc.Forms(sheetname: str, form: str = ''): svc</span>
  </p>
  <p id="par_id751623151751397" class="paragraph" dir="auto">
     <span class="input" data-tooltip="Click on text to copy to clipboard">svc.Forms(sheetname: str, form: int): svc</span>
  </p>
  <div class="embedded">
<a name="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parameters:</h3>
</div>
  <p id="par_id441623090893210" class="paragraph" dir="auto"><span class="emph">sheetname</span>: The name of the sheet, as a string, from which the form will be retrieved.</p>
  <p id="par_id451623063459286" class="paragraph" dir="auto"><span class="emph">form</span>: The name or index corresponding to a form stored in the specified sheet. If this argument is absent, the method will return a list with the names of all forms available in the sheet.</p>
  <div class="embedded">
<a name="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Example:</h3>
</div>
  <p id="par_id251623063305557" class="paragraph" dir="auto">In the following examples, the first line gets the names of all forms stored in "Sheet1" and the second line retrieves the <span class="literal">Form</span> object of the form named "Form_A" which is stored in "Sheet1".</p>
  <div class="embedded">
<a name="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">In Basic</h5>
</div>
  <div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
    Set FormNames = oDoc.Forms("Sheet1")
    Set FormA = oDoc.Forms("Sheet1", "Form_A")
  </code></pre></div>
  <div class="embedded">
<a name="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">In Python</h5>
</div>
  <div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
    form_names = doc.Forms("Sheet1")
    form_A = doc.Forms("Sheet1", "Form_A")
  </code></pre></div>


<a name="GetColumnName"></a>
  
  <a name="bm_id271591632726624"></a>
      <meta itemprop="keywords" content="Calc service,GetColumnName">
  
  <h2 id="hd_id331591632726750" dir="auto">GetColumnName</h2>
  <p id="par_id401591632726431" class="paragraph" dir="auto">Converts a column number ranging between 1 and 1024 into its corresponding letter (column 'A', 'B', ..., 'AMJ'). If the given column number is outside the allowed range, a zero-length string is returned.</p>
  <div class="embedded">
<a name="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Syntax:</h3>
</div>
  <p id="par_id781621539718872" class="paragraph" dir="auto">
    <span class="input" data-tooltip="Click on text to copy to clipboard">svc.GetColumnName(columnnumber: int): str</span>
  </p>
  <div class="embedded">
<a name="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parameters:</h3>
</div>
  <p id="par_id83159163272628" class="paragraph" dir="auto"><span class="emph">columnnumber</span>: The column number as an integer value in the interval 1 ... 1024.</p>
  <div class="embedded">
<a name="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Example:</h3>
</div>
  <div class="embedded">
<a name="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">In Basic</h5>
</div>
  <p id="par_id11621539831303" class="paragraph" dir="auto">Displays a message box with the name of the third column, which by default is "C".</p>
  <div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
    MsgBox oDoc.GetColumnName(3)
  </code></pre></div>
  <div class="embedded">
<a name="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">In Python</h5>
</div>
  <div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
    bas = CreateScriptService("Basic")
    bas.MsgBox(myDoc.GetColumnName(3))
  </code></pre></div>
  <div class="note">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/note.svg" alt="note" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id451611753568778" dir="auto">The maximum number of columns allowed on a Calc sheet is 1024.</p></div>
</div>
<br>


<a name="GetFormula"></a>
  
  <a name="bm_id141593880142749"></a>
      <meta itemprop="keywords" content="Calc service,GetFormula">
  
  <h2 id="hd_id88159388014220" dir="auto">GetFormula</h2>
  <p id="par_id921593880142573" class="paragraph" dir="auto">Get the formula(s) stored in the given range of cells as a single string, a 1D or a 2D array of strings.</p>
  <div class="note">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/note.svg" alt="note" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id291658146319931" dir="auto">The names of Calc functions used in the returned formulas are expressed in English. Visit the Wiki page <a target="_blank" href="https://wiki.documentfoundation.org/Documentation/Calc_Functions/List_of_Functions">List of Calc Functions</a> for a complete list of Calc functions in English.</p></div>
</div>
<br>
  <div class="embedded">
<a name="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Syntax:</h3>
</div>
  <p id="par_id301621540291513" class="paragraph" dir="auto">
    <span class="input" data-tooltip="Click on text to copy to clipboard">svc.GetFormula(range: str): any</span>
  </p>
  <div class="embedded">
<a name="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parameters:</h3>
</div>
  <p id="par_id891593880142588" class="paragraph" dir="auto"><span class="emph">range</span>: The range where to get the formulas from, as a string.</p>
  <div class="embedded">
<a name="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Example:</h3>
</div>
  <div class="embedded">
<a name="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">In Basic</h5>
</div>
  <p id="par_id461611755257141" class="paragraph" dir="auto">The following example returns a 3 by 2 array with the formulas in the range "A1:B3" (3 rows by 2 columns):</p>
  <div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
    arrFormula = oDoc.GetFormula("~.A1:B3")
  </code></pre></div>
  <div class="embedded">
<a name="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">In Python</h5>
</div>
  <div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
    arrFormula = myDoc.GetFormula("~.A1:B3")
  </code></pre></div>


<a name="GetValue"></a>
  
  <a name="bm_id571592231156848"></a>
      <meta itemprop="keywords" content="Calc service,GetValue">
  
  <h2 id="hd_id471592231156242" dir="auto">GetValue</h2>
  <p id="par_id331592231156425" class="paragraph" dir="auto">Get the value(s) stored in the given range of cells as a single value, a 1D array or a 2D array. All values are either doubles or strings.</p>
  <div class="embedded">
<a name="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Syntax:</h3>
</div>
  <p id="par_id51621540380926" class="paragraph" dir="auto">
    <span class="input" data-tooltip="Click on text to copy to clipboard">svc.GetValue(range: str): any</span>
  </p>
  <div class="embedded">
<a name="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parameters:</h3>
</div>
  <p id="par_id91592231156434" class="paragraph" dir="auto"><span class="emph">range</span>: The range where to get the values from, as a string.</p>
  <div class="embedded">
<a name="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Example:</h3>
</div>
  <div class="embedded">
<a name="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">In Basic</h5>
</div>
  <div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
      arrValues = oDoc.GetValue("~.B1:C100")
  </code></pre></div>
  <div class="embedded">
<a name="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">In Python</h5>
</div>
  <div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
    arrValues = myDoc.GetValue("~.B1:C100")
  </code></pre></div>
  <div class="note">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/note.svg" alt="note" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id991611756492772" dir="auto">If a cell contains a date, the number corresponding to that date will be returned. To convert numeric values to dates in Basic scripts, use the Basic <a target="_top" href="en-US/text/sbasic/shared/03100300.html"><span class="literal">CDate</span> builtin function</a>. In Python scripts, use the <a target="_top" href="en-US/text/sbasic/shared/03/sf_basic.html#CDate"><span class="literal">CDate</span> function from the <span class="literal">Basic</span> service.</a></p></div>
</div>
<br>


<a name="ImportFromCSVFile"></a>
  
  <a name="bm_id381593685490638"></a>
      <meta itemprop="keywords" content="Calc service,ImportFromCSVFile">
  
  <h2 id="hd_id151593685490480" dir="auto">ImportFromCSVFile</h2>
  <p id="par_id771593685490395" class="paragraph" dir="auto">Imports the contents of a CSV-formatted text file and places it on a given destination cell.</p>
  <p id="par_id751611756909199" class="paragraph" dir="auto">The destination area is cleared of all contents and formats before inserting the contents of the CSV file. The size of the modified area is fully determined by the contents of the input file.</p>
  <p id="par_id911593685490873" class="paragraph" dir="auto">The method returns a string representing the modified range of cells.</p>
  <div class="embedded">
<a name="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Syntax:</h3>
</div>
  <p id="par_id661621540542882" class="paragraph" dir="auto">
    <span class="input" data-tooltip="Click on text to copy to clipboard">svc.ImportFromCSVFile(filename: str, destinationcell: str, [filteroptions: str]): str</span>
  </p>
  <div class="embedded">
<a name="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parameters:</h3>
</div>
  <p id="par_id851593685490824" class="paragraph" dir="auto"><span class="emph">filename</span>: Identifies the file to open. It must follow the <span class="literal">SF_FileSystem.FileNaming</span> notation.</p>
  <p id="par_id641593685490936" class="paragraph" dir="auto"><span class="emph">destinationcell</span>: The destination cell to insert the imported data, as a string. If instead a range is given, only its top-left cell is considered.</p>
  <p id="par_id641593685863838" class="paragraph" dir="auto"><span class="emph">filteroptions</span>: The arguments for the CSV input filter. The default filter makes following assumptions:</p>
  <ul itemprop="Unordered" itemscope="true" itemtype="http://schema.org/ItemList" dir="auto">
        <li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
            <p id="par_id661593686250471" class="listitem" dir="auto">The input file encoding is UTF8.</p>
        </li>
        <li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
            <p id="par_id161593686260876" class="listitem" dir="auto">The field separator is a comma, a semi-colon or a Tab character.</p>
        </li>
        <li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
            <p id="par_id711593686274293" class="listitem" dir="auto">The string delimiter is the double quote (").</p>
        </li>
        <li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
            <p id="par_id171593686280838" class="listitem" dir="auto">All lines are included.</p>
        </li>
        <li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
            <p id="par_id881593686287161" class="listitem" dir="auto">Quoted strings are formatted as text.</p>
        </li>
        <li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
            <p id="par_id161593686293473" class="listitem" dir="auto">Special numbers are detected.</p>
        </li>
        <li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
            <p id="par_id791593686300499" class="listitem" dir="auto">All columns are presumed to be texts, except if recognized as valid numbers.</p>
        </li>
        <li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
            <p id="par_id381593686307406" class="listitem" dir="auto">The language is English/US, which implies that the decimal separator is "." and the thousands separator is ",".</p>
        </li>
  </ul>
  <div class="embedded">
<a name="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Example:</h3>
</div>
  <div class="embedded">
<a name="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">In Basic</h5>
</div>
  <div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
    oDoc.ImportFromCSVFile("C:\Temp\myCSVFile.csv", "SheetY.C5")
  </code></pre></div>
  <div class="embedded">
<a name="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">In Python</h5>
</div>
  <div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
    myDoc.ImportFromCSVFile(r"C:\Temp\myCSVFile.csv", "SheetY.C5")
  </code></pre></div>
  <div class="tip">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/tip.svg" alt="tip" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id531611757154931" dir="auto">To learn more about the CSV Filter Options, refer to the <a target="_top" href="en-US/text/shared/guide/csv_params.html">CSV Filter Options help page</a>.</p></div>
</div>
<br>


<a name="ImportFromDatabase"></a>
  
  <a name="bm_id281599568986735"></a>
      <meta itemprop="keywords" content="Calc service,ImportFromDatabase">
  
  <h2 id="hd_id1001599568986535" dir="auto">ImportFromDatabase</h2>
  <p id="par_id881599568986824" class="paragraph" dir="auto">Imports the contents of a database table, query or resultset, i.e. the result of a SELECT SQL command, inserting it on a destination cell.</p>
  <p id="par_id81611763957509" class="paragraph" dir="auto">The destination area is cleared of all contents and formats before inserting the imported contents. The size of the modified area is fully determined by the contents in the table or query.</p>
  <p id="par_id51599568986387" class="paragraph" dir="auto">The method returns <span class="literal">True</span> when the import was successful.</p>
  <div class="embedded">
<a name="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Syntax:</h3>
</div>
  <p id="par_id451621542093265" class="paragraph" dir="auto">
    <span class="input" data-tooltip="Click on text to copy to clipboard">svc.ImportFromDatabase(filename: str = "", registrationname: str = "", destinationcell: str = "", sqlcommand: str = "", directsql: bool): bool</span>
  </p>
  <div class="embedded">
<a name="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parameters:</h3>
</div>
  <p id="par_id311599568986784" class="paragraph" dir="auto"><span class="emph">filename</span>: Identifies the file to open. It must follow the <span class="literal">SF_FileSystem.FileNaming</span> notation.</p>
  <p id="par_id711596555746281" class="paragraph" dir="auto"><span class="emph">registrationname</span>: The name to use to find the database in the databases register. This argument is ignored if a <span class="literal">filename</span> is provided.</p>
  <p id="par_id211599568986329" class="paragraph" dir="auto"><span class="emph">destinationcell</span>: The destination of the imported data, as a string. If a range is given, only its top-left cell is considered.</p>
  <p id="par_id451599489278429" class="paragraph" dir="auto"><span class="emph">sqlcommand</span>: A table or query name (without surrounding quotes or square brackets) or a SELECT SQL statement in which table and field names may be surrounded by square brackets or quotes to improve its readability.</p>
  <p id="par_id271599489278141" class="paragraph" dir="auto"><span class="emph">directsql</span>: When <span class="literal">True</span>, the SQL command is sent to the database engine without pre-analysis. Default is <span class="literal">False</span>. The argument is ignored for tables. For queries, the applied option is the one set when the query was defined.</p>
  <div class="embedded">
<a name="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Example:</h3>
</div>
  <div class="embedded">
<a name="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">In Basic</h5>
</div>
  <div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
    oDoc.ImportFromDatabase("C:\Temp\myDbFile.odb", , "SheetY.C5", "SELECT * FROM [Employees] ORDER BY [LastName]")
  </code></pre></div>
  <div class="embedded">
<a name="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">In Python</h5>
</div>
  <div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
    myDoc.ImportFromDatabase(r"C:\Temp\myDbFile.odb", , "SheetY.C5", "SELECT * FROM [Employees] ORDER BY [LastName]")
  </code></pre></div>


<a name="InsertSheet"></a>
  
  <a name="bm_id511591698472720"></a>
      <meta itemprop="keywords" content="Calc service,InsertSheet">
  
  <h2 id="hd_id661591698472897" dir="auto">InsertSheet</h2>
  <p id="par_id121591698472929" class="paragraph" dir="auto">Inserts a new empty sheet before an existing sheet or at the end of the list of sheets.</p>
  <div class="embedded">
<a name="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Syntax:</h3>
</div>
  <p id="par_id531621619656738" class="paragraph" dir="auto">
    <span class="input" data-tooltip="Click on text to copy to clipboard">svc.InsertSheet(sheetname: str, [beforesheet: any]): bool</span>
  </p>
  <div class="embedded">
<a name="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parameters:</h3>
</div>
  <p id="par_id941591698472748" class="paragraph" dir="auto"><span class="emph">sheetname</span>: The name of the new sheet.</p>
  <p id="par_id84159169847269" class="paragraph" dir="auto"><span class="emph">beforesheet</span>: The name (string) or index (numeric, starting from 1) of the sheet before which to insert the new sheet. This argument is optional and the default behavior is to insert the sheet at the last position.</p>
  <div class="embedded">
<a name="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Example:</h3>
</div>
  <p id="par_id241611764359510" class="paragraph" dir="auto">The following example inserts a new empty sheet named "SheetX" and places it before "SheetY":</p>
  <div class="embedded">
<a name="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">In Basic</h5>
</div>
  <div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
    oDoc.InsertSheet("SheetX", "SheetY")
  </code></pre></div>
  <div class="embedded">
<a name="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">In Python</h5>
</div>
  <div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
    myDoc.InsertSheet("SheetX", "SheetY")
  </code></pre></div>


<a name="MoveRange"></a>
  
  <a name="bm_id381592569476239"></a>
      <meta itemprop="keywords" content="Calc service,MoveRange">
  
  <h2 id="hd_id721592569476510" dir="auto">MoveRange</h2>
  <p id="par_id6415925694762" class="paragraph" dir="auto">Moves a specified source range to a destination range of cells. The method returns a string representing the modified range of cells. The dimension of the modified area is fully determined by the size of the source area.</p>
  <div class="embedded">
<a name="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Syntax:</h3>
</div>

  <p id="par_id211621620062306" class="paragraph" dir="auto">
    <span class="input" data-tooltip="Click on text to copy to clipboard">svc.MoveRange(source: str, destination: str): str</span>
  </p>
  <div class="embedded">
<a name="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parameters:</h3>
</div>
  <p id="par_id571592569476332" class="paragraph" dir="auto"><span class="emph">source</span>: The source range of cells, as a string.</p>
  <p id="par_id891592569476362" class="paragraph" dir="auto"><span class="emph">destination</span>: The destination cell, as a string. If a range is given, its top-left cell is considered as the destination.</p>
  <div class="embedded">
<a name="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Example:</h3>
</div>
  <div class="embedded">
<a name="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">In Basic</h5>
</div>
  <div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
    oDoc.MoveRange("SheetX.A1:F10", "SheetY.C5")
  </code></pre></div>
  <div class="embedded">
<a name="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">In Python</h5>
</div>
  <div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
    myDoc.MoveRange("SheetX.A1:F10", "SheetY.C5")
  </code></pre></div>


<a name="MoveSheet"></a>
  
  <a name="bm_id561591698903617"></a>
      <meta itemprop="keywords" content="Calc service,MoveSheet">
  
  <h2 id="hd_id761591698903271" dir="auto">MoveSheet</h2>
  <p id="par_id831591698903829" class="paragraph" dir="auto">Moves an existing sheet and places it before a specified sheet or at the end of the list of sheets.</p>
  <div class="embedded">
<a name="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Syntax:</h3>
</div>
  <p id="par_id1001621620119732" class="paragraph" dir="auto">
    <span class="input" data-tooltip="Click on text to copy to clipboard">svc.MoveSheet(sheetname: str, [beforesheet: any]): bool</span>
  </p>
  <div class="embedded">
<a name="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parameters:</h3>
</div>
  <p id="par_id351591698903911" class="paragraph" dir="auto"><span class="emph">sheetname</span>: The name of the sheet to move. The sheet must exist or an exception is raised.</p>
  <p id="par_id9159169890334" class="paragraph" dir="auto"><span class="emph">beforesheet</span>: The name (string) or index (numeric, starting from 1) of the sheet before which the original sheet will be placed. This argument is optional and the default behavior is to move the sheet to the last position.</p>
  <div class="embedded">
<a name="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Example:</h3>
</div>
  <p id="par_id951611766058734" class="paragraph" dir="auto">The example below moves the existing sheet "SheetX" and places it before "SheetY":</p>
  <div class="embedded">
<a name="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">In Basic</h5>
</div>
  <div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
    oDoc.MoveSheet("SheetX", "SheetY")
  </code></pre></div>
  <div class="embedded">
<a name="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">In Python</h5>
</div>
  <div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
    myDoc.MoveSheet("SheetX", "SheetY")
  </code></pre></div>


<a name="Offset"></a>
  
  <a name="bm_id29159223350681"></a>
      <meta itemprop="keywords" content="Calc service,Offset">
  
  <h2 id="hd_id61592233506228" dir="auto">Offset</h2>
  <p id="par_id51592233506371" class="paragraph" dir="auto">Returns a new range (as a string) offset by a certain number of rows and columns from a given range.</p>
  <p id="par_id61611768400376" class="paragraph" dir="auto">This method has the same behavior as the homonymous Calc's <a target="_top" href="en-US/text/scalc/01/04060109.html">Offset function</a>.</p>
  <div class="embedded">
<a name="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Syntax:</h3>
</div>
  <p id="par_id301621620394077" class="paragraph" dir="auto">
    <span class="input" data-tooltip="Click on text to copy to clipboard">svc.Offset(reference: str, rows: int = 0, columns: int = 0, [height: int], [width: int]): str</span>
  </p>
  <div class="embedded">
<a name="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parameters:</h3>
</div>
  <p id="par_id901592233506293" class="paragraph" dir="auto"><span class="emph">reference</span>: The range, as a string, that the method will use as reference to perform the offset operation.</p>
  <p id="par_id781592234124856" class="paragraph" dir="auto"><span class="emph">rows</span>: The number of rows by which the initial range is offset upwards (negative value) or downwards (positive value). Use 0 (default) to stay in the same row.</p>
  <p id="par_id971592234138769" class="paragraph" dir="auto"><span class="emph">columns</span>: The number of columns by which the initial range is offset to the left (negative value) or to the right (positive value). Use 0 (default) to stay in the same column.</p>
  <p id="par_id321592234150061" class="paragraph" dir="auto"><span class="emph">height</span>: The vertical height for an area that starts at the new range position. Omit this argument when no vertical resizing is needed.</p>
  <p id="par_id271592234165247" class="paragraph" dir="auto"><span class="emph">width</span>: The horizontal width for an area that starts at the new range position. Omit this argument when no horizontal resizing is needed.</p>
  <p id="par_id871592234172652" class="paragraph" dir="auto">Arguments <span class="literal">rows</span> and <span class="literal">columns</span> must not lead to zero or negative start row or column.</p>
  <p id="par_id211592234180073" class="paragraph" dir="auto">Arguments <span class="literal">height</span> and <span class="literal">width</span> must not lead to zero or negative count of rows or columns.</p>
  <div class="embedded">
<a name="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Example:</h3>
</div>
  <div class="embedded">
<a name="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">In Basic</h5>
</div>
  <div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
    oDoc.Offset("A1", 2, 2)
    'SheetX.$C$3 (A1 moved by two rows and two columns down)
    oDoc.Offset("A1", 2, 2, 5, 6)
    'SheetX.$C$3:$H$7 (A1 offset by two rows and columns with width of 5 rows and 6 columns)
  </code></pre></div>
  <div class="embedded">
<a name="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">In Python</h5>
</div>
  <div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
    myDoc.Offset("A1", 2, 2)
    myDoc.Offset("A1", 2, 2, 5, 6)
  </code></pre></div>


<a name="OpenRangeSelector"></a>
  
  <a name="bm_id29159223350681"></a>
      <meta itemprop="keywords" content="Calc service,OpenRangeSelector">
  
  <h2 id="hd_id61592233506804" dir="auto">OpenRangeSelector</h2>
  <p id="par_id51592233506021" class="paragraph" dir="auto">Opens a non-modal dialog that can be used to select a range in the document and returns a string containing the selected range.</p>
  <div class="note">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/note.svg" alt="note" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id301637936295380" dir="auto">This method opens the same dialog that is used by LibreOffice when the Shrink button is pressed. For example, the <span class="menuitem">Tools - Goal Seek</span> dialog has a Shrink button to the right of the <span class="menuitem">Formula cell</span> field.</p></div>
</div>
<br>
  <p id="par_id551637936545121" class="paragraph" dir="auto">This method does not change the current selection.</p>
  <div class="embedded">
<a name="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Syntax:</h3>
</div>
  <p id="par_id301621620394202" class="paragraph" dir="auto">
    <span class="input" data-tooltip="Click on text to copy to clipboard">svc.OpenRangeSelector(opt title: str, opt selection: str, singlecell: bool = False, closeafterselect: bool = True): str</span>
  </p>
  <div class="embedded">
<a name="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parameters:</h3>
</div>
  <p id="par_id901592233506001" class="paragraph" dir="auto"><span class="emph">title</span>: The title of the dialog, as a string.</p>
  <p id="par_id781592234124502" class="paragraph" dir="auto"><span class="emph">selection</span>: An optional range that is initially selected when the dialog is displayed.</p>
  <p id="par_id971592234138989" class="paragraph" dir="auto"><span class="emph">singlecell</span>: When <span class="literal">True</span> (default) only single-cell selection is allowed. When <span class="literal">False</span> range selection is allowed.</p>
  <p id="par_id321592234150345" class="paragraph" dir="auto"><span class="emph">closeafterselect</span>: When <span class="literal">True</span> (default) the dialog is closed immediately after the selection is made. When <span class="literal">False</span> the user can change the selection as many times as needed and then manually close the dialog.</p>
  <div class="embedded">
<a name="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Example:</h3>
</div>
  <div class="embedded">
<a name="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">In Basic</h5>
</div>
  <div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
    Dim sRange as String
    sRange = oDoc.OpenRangeSelector(Title := "Select a range")
  </code></pre></div>
  <div class="embedded">
<a name="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">In Python</h5>
</div>
  <div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
    sRange = myDoc.OpenRangeSelector(title = "Select a range")
  </code></pre></div>


<a name="Printf"></a>
  
  <a name="bm_id29159223356581"></a>
      <meta itemprop="keywords" content="Calc service,Printf">
  
  <h2 id="hd_id61592233503364" dir="auto">Printf</h2>
  <p id="par_id51592233503441" class="paragraph" dir="auto">Returns the input string after substituting its token characters by their values in a given range.</p>
  <p id="par_id551637936596521" class="paragraph" dir="auto">This method does not change the current selection.</p>
  <div class="tip">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/tip.svg" alt="tip" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id171637938442558" dir="auto">This method can be used to quickly extract specific parts of a range name, such as the sheet name or first cell column and row, and use them to compose a new range address.</p></div>
</div>
<br>
  <div class="embedded">
<a name="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Syntax:</h3>
</div>
  <p id="par_id301621620394154" class="paragraph" dir="auto">
    <span class="input" data-tooltip="Click on text to copy to clipboard">svc.Printf(inputstr: str, range: str, tokencharacter: str = "%"): str</span>
  </p>
  <div class="embedded">
<a name="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parameters:</h3>
</div>
  <p id="par_id901592233506232" class="paragraph" dir="auto"><span class="emph">inputstr</span>: The string containing the tokens that will be replaced by the corresponding values in <span class="literal">range</span>.</p>
  <p id="par_id781592234161102" class="paragraph" dir="auto"><span class="emph">range</span>: A <span class="literal">RangeName</span> from which values will be extracted. If it contains a sheet name, the sheet must exist.</p>
  <p id="par_id971592234102889" class="paragraph" dir="auto"><span class="emph">tokencharacter</span>: Character used to identify tokens. By default "%" is the token character. The following tokens are accepted:</p>
  <ul itemprop="Unordered" itemscope="true" itemtype="http://schema.org/ItemList" dir="auto">
    <li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
        <p id="par_id261637943912156" class="listitem" dir="auto"><span class="emph">%S</span> - The sheet name containing the range, including single quotes when necessary.</p>
    </li>
    <li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
        <p id="par_id441637943912380" class="listitem" dir="auto"><span class="emph">%R1</span> - The row number of the top left cell of the range.</p>
    </li>
    <li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
        <p id="par_id521637943912620" class="listitem" dir="auto"><span class="emph">%C1</span> - The column letter of the top left cell of the range.</p>
    </li>
    <li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
        <p id="par_id371637943912860" class="listitem" dir="auto"><span class="emph">%R2</span> - The row number of the bottom right cell of the range.</p>
    </li>
    <li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
        <p id="par_id291637943913116" class="listitem" dir="auto"><span class="emph">%C2</span> - The column letter of the bottom right cell of the range.</p>
    </li>
  </ul>
  <div class="embedded">
<a name="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Example:</h3>
</div>
  <div class="embedded">
<a name="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">In Basic</h5>
</div>
  <p id="par_id941637943467476" class="paragraph" dir="auto">The example below extracts each element of the <span class="literal">RangeName</span> defined in <span class="literal">sRange</span> and uses them to compose a message.</p>
  <div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
    Dim sRange as String, sInputStr as String
    sRange = "Sheet1.A1:E10"
    sInputStr = "Sheet name: %S" &amp; Chr(10) &amp; _
                "First row: %R1" &amp; Chr(10) &amp; _
                "First column %C1" &amp; Chr(10) &amp; _
                "Last row %R2" &amp; Chr(10) &amp; _
                "Last column %C2"
    MsgBox oDoc.Printf(sInputStr, sRange)
  </code></pre></div>
  <p id="par_id241637944350648" class="paragraph" dir="auto">The <span class="literal">Printf</span> method can be combined with <span class="literal">SetFormula</span> to create formulas over multiple cells. For instance, consider a table with numeric values in the range "A1:E10" from which formulas are to be created to sum the values in each row and place the results in the range "F1:F10":</p>
  <div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
    Dim sFormula as String, sRange as String
    sRange = "A1:E10"
    ' Note the use of the "$" character
    sFormula = "=SUM($%C1%R1:$%C2%R1)"
    oDoc.SetFormula("F1:F10", oDoc.Printf(sFormula, sRange))
  </code></pre></div>
  <div class="embedded">
<a name="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">In Python</h5>
</div>
  <div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
    sRange = "Sheet1.A1:E10"
    sInputStr = "Sheet name: %S\n" \
                "First row: %R1\n" \
                "First column %C1\n" \
                "Last row %R2\n" \
                "Last column %C2"
    bas = CreateScriptService("Basic")
    bas.MsgBox(myDoc.Printf(sInputStr, sRange))
  </code></pre></div>
  <div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
    sRange = "A1:E10
    sFormula = "=SUM($%C1%R1:$%C2%R1)"
    myDoc.SetFormula("F1:F10", myDoc.Printf(sFormula, sRange))
  </code></pre></div>


<a name="PrintOut"></a>
  
  <a name="bm_id721985200121249"></a>
    <meta itemprop="keywords" content="Calc service,PrintOut">
  
  <h2 id="hd_id261589202101415" dir="auto">PrintOut</h2>
  <p id="par_id156589200121138" class="paragraph" dir="auto">This method sends the contents of the given sheet to the default printer or to the printer defined by the <span class="literal">SetPrinter</span> method of the <span class="literal">Document</span> service.</p>
  <p id="par_id981611169416934" class="paragraph" dir="auto">Returns <span class="literal">True</span> if the sheet was successfully printed.</p>
  <div class="embedded">
<a name="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Syntax:</h3>
</div>
  <p id="par_id1001622827822169" class="paragraph" dir="auto">
    <span class="input" data-tooltip="Click on text to copy to clipboard">svc.PrintOut(opt sheetname: str, pages: str = "", copies: num = 1): bool</span>
  </p>
  <div class="embedded">
<a name="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parameters:</h3>
</div>
  <p id="par_id368519200121646" class="paragraph" dir="auto"><span class="emph">sheetname</span>: The sheet to print, default is the active sheet.</p>
  <p id="par_id211635436910093" class="paragraph" dir="auto"><span class="emph">pages</span>: The pages to print as a string, like in the user interface. Example: "1-4;10;15-18". Default is all pages.</p>
  <p id="par_id141635436912146" class="paragraph" dir="auto"><span class="emph">copies</span>: The number of copies. Default is 1.</p>
  <div class="embedded">
<a name="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Example:</h3>
</div>
  <div class="embedded">
<a name="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">In Basic</h5>
</div>
  <div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
    If oDoc.PrintOut("SheetX", "1-4;10;15-18", Copies := 2) Then
        ' ...
    End If
  </code></pre></div>
  <div class="embedded">
<a name="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">In Python</h5>
</div>
  <div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
    if doc.PrintOut('SheetX', copies=3, pages='45-88'):
        # ...
  </code></pre></div>


<a name="RemoveDuplicates"></a>
  
  <a name="bm_id821596699086119"></a>
      <meta itemprop="keywords" content="Calc service,RemoveDuplicates">
  
  <h2 id="hd_id311591699085124" dir="auto">RemoveDuplicates</h2>
  <p id="par_id661591699086251" class="paragraph" dir="auto">Removes duplicate rows from a specified range. The comparison to determine if a given row is a duplicate is done based on a subset of columns in the range.</p>
  <p id="par_id111674511007536" class="paragraph" dir="auto">This method returns a string containing the resulting range.</p>
  <div class="note">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/note.svg" alt="note" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id831674511881468" dir="auto">The removal of duplicate rows is done starting at the first row in the range moving downwards, meaning that if two or more rows are duplicates then only the first one is kept.</p></div>
</div>
<br>
  <div class="embedded">
<a name="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Syntax:</h3>
</div>
  <p id="par_id991621620503647" class="paragraph" dir="auto">
    <span class="input" data-tooltip="Click on text to copy to clipboard">svc.RemoveDuplicates(range: str, opt columns: int[0..*], header: bool = False, casesensitive: bool = False, mode: str = "COMPACT"): str</span>
  </p>
  <div class="embedded">
<a name="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parameters:</h3>
</div>
  <p id="par_id331591699082900" class="paragraph" dir="auto"><span class="emph">range</span>: The range from which duplicates will be removed, as a string.</p>
  <p id="par_id331591699082848" class="paragraph" dir="auto"><span class="emph">columns</span>: An array containing column numbers indicating which columns will be considered to determine if a row is a duplicate or not. If this argument is left blank, then only the first column is used. Items in this array must be in the interval between 1 and the range width.</p>
  <p id="par_id331591699082147" class="paragraph" dir="auto"><span class="emph">header</span>: Specifies whether the first row is a header row (Default = <span class="literal">False</span>).</p>
  <p id="par_id331591699082231" class="paragraph" dir="auto"><span class="emph">casesensitive</span>: Specifies whether string comparisons are case-sensitive (Default = <span class="literal">False</span>).</p>
  <p id="par_id331591699082446" class="paragraph" dir="auto"><span class="emph">mode</span>: Specifies what to do with duplicate rows. If <span class="literal">mode = "CLEAR"</span> then duplicates are simply removed from the sheet leaving the cells blank. If <span class="literal">mode = "COMPACT"</span> then duplicates are removed and empty rows are compacted up (Default = <span class="literal">"COMPACT"</span>).</p>
  <div class="embedded">
<a name="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Example:</h3>
</div>
  <div class="embedded">
<a name="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">In Basic</h5>
</div>
  <div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
    ' Removes duplicate rows where values in column A are duplicate
    ' Note that all optional arguments use their default value
    oDoc.RemoveDuplicates("A1:B10")
    ' Removes duplicate rows considering that the first row contains headers
    ' Columns A and B are used to determine if a row is a duplicate
    ' Cells containing duplicate values are left blank
    oDoc.RemoveDuplicates("A1:D10", columns := Array(1, 2), header := True, mode := "CLEAR")
  </code></pre></div>
  <div class="embedded">
<a name="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">In Python</h5>
</div>
  <div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
    myDoc.RemoveDuplicates("A1:B10")
    myDoc.RemoveDuplicates("A1:D10", columns = (1, 2), header = True, mode = "CLEAR")
  </code></pre></div>


<a name="RemoveSheet"></a>
  
  <a name="bm_id821591699085559"></a>
      <meta itemprop="keywords" content="Calc service,RemoveSheet">
  
  <h2 id="hd_id311591699085933" dir="auto">RemoveSheet</h2>
  <p id="par_id661591699085351" class="paragraph" dir="auto">Removes an existing sheet from the document.</p>
  <div class="embedded">
<a name="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Syntax:</h3>
</div>
  <p id="par_id991621620588147" class="paragraph" dir="auto">
    <span class="input" data-tooltip="Click on text to copy to clipboard">svc.RemoveSheet(sheetname: str): bool</span>
  </p>
  <div class="embedded">
<a name="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parameters:</h3>
</div>
  <p id="par_id331591699085330" class="paragraph" dir="auto"><span class="emph">sheetname</span>: The name of the sheet to remove.</p>
  <div class="embedded">
<a name="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Example:</h3>
</div>
  <div class="embedded">
<a name="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">In Basic</h5>
</div>
  <div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
    oDoc.RemoveSheet("SheetY")
  </code></pre></div>
  <div class="embedded">
<a name="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">In Python</h5>
</div>
  <div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
    myDoc.RemoveSheet("SheetY")
  </code></pre></div>


<a name="RenameSheet"></a>
  
  <a name="bm_id781591704316677"></a>
      <meta itemprop="keywords" content="Calc service,RenameSheet">
  
  <h2 id="hd_id171591704316197" dir="auto">RenameSheet</h2>
  <p id="par_id971591704316873" class="paragraph" dir="auto">Renames the given sheet and returns <span class="literal">True</span> if successful.</p>
  <div class="embedded">
<a name="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Syntax:</h3>
</div>
  <p id="par_id301621620709359" class="paragraph" dir="auto">
    <span class="input" data-tooltip="Click on text to copy to clipboard">svc.RenameSheet(sheetname: str, newname: str): bool</span>
  </p>
  <div class="embedded">
<a name="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parameters:</h3>
</div>
  <p id="par_id161591704316337" class="paragraph" dir="auto"><span class="emph">sheetname</span>: The name of the sheet to rename.</p>
  <p id="par_id931591704316998" class="paragraph" dir="auto"><span class="emph">newname</span>: the new name of the sheet. It must not exist yet.</p>
  <div class="embedded">
<a name="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Example:</h3>
</div>
  <p id="par_id351611775260443" class="paragraph" dir="auto">This example renames the active sheet to "SheetY":</p>
  <div class="embedded">
<a name="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">In Basic</h5>
</div>
  <div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
    oDoc.RenameSheet("~", "SheetY")
  </code></pre></div>
  <div class="embedded">
<a name="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">In Python</h5>
</div>
  <div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
    mydoc.RenameSheet("~", "SheetY")
  </code></pre></div>


<a name="SetArray"></a>
  
  <a name="bm_id221592745582441"></a>
      <meta itemprop="keywords" content="Calc service,SetArray">
  
  <h2 id="hd_id831592745582224" dir="auto">SetArray</h2>
  <p id="par_id191592745582983" class="paragraph" dir="auto">Stores the given value starting from a specified target cell. The updated area expands itself from the target cell or from the top-left corner of the given range to accommodate the size of the input <span class="literal">value</span> argument. Vectors are always expanded vertically.</p>
  <p id="par_id671592745582573" class="paragraph" dir="auto">The method returns a string representing the modified area as a range of cells.</p>
  <div class="embedded">
<a name="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Syntax:</h3>
</div>
  <p id="par_id401621620954121" class="paragraph" dir="auto">
    <span class="input" data-tooltip="Click on text to copy to clipboard">svc.SetArray(targetcell: str, value: any): str</span>
  </p>
  <div class="embedded">
<a name="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parameters:</h3>
</div>
  <p id="par_id801592745582116" class="paragraph" dir="auto"><span class="emph">targetcell</span>: The cell or a range as a string from where to start to store the given value.</p>
  <p id="par_id321592745582192" class="paragraph" dir="auto"><span class="emph">value</span>: A scalar, a vector or an array (in Python, one or two-dimensional lists and tuples) with the new values to be stored from the target cell or from the top-left corner of the range if <span class="literal">targetcell</span> is a range. The new values must be strings, numeric values or dates. Other types will cause the corresponding cells to be emptied.</p>
  <div class="embedded">
<a name="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Example:</h3>
</div>
  <div class="embedded">
<a name="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">In Basic</h5>
</div>
  <p id="par_id331611776151376" class="paragraph" dir="auto">The following example uses the builtin <a target="_top" href="en-US/text/sbasic/shared/03104300.html">DimArray function</a> to create an array and then store it in cell "A1":</p>
  <div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
    Dim arrData as Variant
    arrData = DimArray(2, 1)
    arrData(0, 0) = 1 : arrData(1, 0) = 2 : arrData(2, 0) = 3
    arrData(0, 1) = "One" : arrData(1, 1) = "Two" : arrData(2, 1) = "Three"
    oDoc.SetArray("Sheet1.A1", arrData)
  </code></pre></div>
  <p id="par_id601611775600983" class="paragraph" dir="auto">This example uses the <span class="literal">RangeInit</span> method of the <a target="_top" href="en-US/text/sbasic/shared/03/sf_array.html#RangeInit">ScriptForge Array service</a> to create an array with values that are then stored from cell "A1" and downwards.</p>
  <div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
    'Fill 1st column with values from 1 to 1000
    oDoc.SetArray("Sheet1.A1", SF_Array.RangeInit(1, 1000))
  </code></pre></div>
  <div class="embedded">
<a name="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">In Python</h5>
</div>
  <div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
    arrData = ((1, "One"), (2, "Two"), (3, "Three"))
    myDoc.SetArray("Sheet1.A1", arrData)
  </code></pre></div>
  <div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
    myDoc.SetArray("Sheet1.A1", tuple(i + 1 for i in range(1000)))
  </code></pre></div>
  <div class="tip">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/tip.svg" alt="tip" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id291592905671530" dir="auto">To dump the full contents of an array in a sheet, use <span class="emph">SetArray</span>. To dump the contents of an array only within the boundaries of the targeted range of cells, use <span class="emph">SetValue</span>.</p></div>
</div>
<br>


<a name="SetCellStyle"></a>
  
  <a name="bm_id21595767687885"></a>
      <meta itemprop="keywords" content="Calc service,SetCellStyle">
  
  <h2 id="hd_id201595767687377" dir="auto">SetCellStyle</h2>
  <p id="par_id521595767687154" class="paragraph" dir="auto">Applies the specified cell style to the given target range. The full range is updated and the remainder of the sheet is left untouched. If the cell style does not exist, an error is raised.</p>
  <p id="par_id70159576768715" class="paragraph" dir="auto">The method returns a string representing the modified area as a range of cells.</p>
  <div class="embedded">
<a name="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Syntax:</h3>
</div>
  <p id="par_id731621622877726" class="paragraph" dir="auto">
    <span class="input" data-tooltip="Click on text to copy to clipboard">svc.SetCellStyle(targetrange: str, style: str, opt filterformula: str, opt filterscope: str): str</span>
  </p>
  <div class="embedded">
<a name="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parameters:</h3>
</div>
  <p id="par_id22159576768782" class="paragraph" dir="auto"><span class="emph">targetrange</span>: The range to which the style will be applied, as a string.</p>
  <p id="par_id181595767687247" class="paragraph" dir="auto"><span class="emph">style</span>: The name of the cell style to apply.</p>
  <div class="embedded">
<a name="filterformula_desc"></a>
    <p id="par_id351670939954166" class="paragraph" dir="auto"><span class="emph">filterformula:</span> A Calc formula that shall be applied to the given range to determine which cells will be affected. The specified formula must return <span class="literal">True</span> or <span class="literal">False</span>. If this argument is not specified, then all cells in the range are affected.</p>
    <p id="par_id461670939954392" class="paragraph" dir="auto"><span class="emph">filterscope:</span> Determines how <span class="literal">filterformula</span> is expanded to the given range. This argument is mandatory if a <span class="literal">filterformula</span> is specified. The following values are accepted:</p>
    <ul itemprop="Unordered" itemscope="true" itemtype="http://schema.org/ItemList" dir="auto">
      <li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
        <p id="par_id991670941074213" class="listitem" dir="auto"><span class="emph">"CELL":</span> The formula specified in the <span class="literal">filterformula</span> argument is expanded once for each cell in <span class="literal">range</span>.</p>
      </li>
      <li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
        <p id="par_id911670941074926" class="listitem" dir="auto"><span class="emph">"ROW":</span> The formula specified in the <span class="literal">filterformula</span> argument is expanded once for each row in <span class="literal">range</span>.</p>
      </li>
      <li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
        <p id="par_id581670941075101" class="listitem" dir="auto"><span class="emph">"COLUMN":</span> The formula specified in the <span class="literal">filterformula</span> argument is expanded once for each column in <span class="literal">range</span>.</p>
      </li>
    </ul>
  </div>
  <div class="embedded">
<a name="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Example:</h3>
</div>
  <div class="embedded">
<a name="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">In Basic</h5>
</div>
  <div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
    oDoc.SetCellStyle("A1:J1", "Heading 1")
    oDoc.SetCellStyle("A2:J100", "Neutral")
  </code></pre></div>
  <div class="embedded">
<a name="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">In Python</h5>
</div>
  <div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
    myDoc.SetCellStyle("A1:J1", "Heading 1")
    myDoc.SetCellStyle("A2:J100", "Neutral")
  </code></pre></div>
  <div class="tip">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/tip.svg" alt="tip" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id461670942481294" dir="auto">Refer to the <a target="_top" href="en-US/text/sbasic/shared/03/sf_calc.html#ClearAll"><span class="literal">ClearAll</span></a> method documentation for examples on how to use the arguments <span class="literal">filterformula</span> and <span class="literal">filterscope</span>.</p></div>
</div>
<br>


<a name="SetFormula"></a>
  
  <a name="bm_id231593880376363"></a>
      <meta itemprop="keywords" content="Calc service,SetFormula">
  
  <h2 id="hd_id191593880376344" dir="auto">SetFormula</h2>
  <p id="par_id481593880376480" class="paragraph" dir="auto">Inserts the given (array of) formula(s) in the specified range. The size of the modified area is equal to the size of the range.</p>
  <p id="par_id711593880376106" class="paragraph" dir="auto">The method returns a string representing the modified area as a range of cells.</p>
  <div class="embedded">
<a name="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Syntax:</h3>
</div>
  <p id="par_id701621623027410" class="paragraph" dir="auto">
    <span class="input" data-tooltip="Click on text to copy to clipboard">svc.SetFormula(targetrange: str, formula: any): str</span>
  </p>
  <div class="embedded">
<a name="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parameters:</h3>
</div>
  <p id="par_id891593880376776" class="paragraph" dir="auto"><span class="emph">targetrange</span>: The range to insert the formulas, as a string.</p>
  <p id="par_id941593880376500" class="paragraph" dir="auto"><span class="emph">formula</span>: A string, a vector or an array of strings with the new formulas for each cell in the target range.</p>
  <p id="par_id551593880376513" class="paragraph" dir="auto">The full range is updated and the remainder of the sheet is left unchanged.</p>
  <p id="par_id811593880756356" class="paragraph" dir="auto">If the given formula is a string, the unique formula is pasted along the whole range with adjustment of the relative references.</p>
  <p id="par_id491593880857823" class="paragraph" dir="auto">If the size of <span class="literal">formula</span> is smaller than the size of <span class="literal">targetrange</span>, then the remaining cells are emptied.</p>
  <p id="par_id701611778103306" class="paragraph" dir="auto">If the size of <span class="literal">formula</span> is larger than the size of <span class="literal">targetrange</span>, then the formulas are only partially copied until it fills the size of <span class="literal">targetrange</span>.</p>
  <p id="par_id761611777946581" class="paragraph" dir="auto">Vectors are always expanded vertically, except if <span class="literal">targetrange</span> has a height of exactly 1 row.</p>
  <div class="note">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/note.svg" alt="note" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id431657568413185" dir="auto">Calc functions used in the <span class="literal">formula</span> argument must be expressed using their English names. Visit the Wiki page <a target="_blank" href="https://wiki.documentfoundation.org/Documentation/Calc_Functions/List_of_Functions">List of Calc Functions</a> for a complete list of Calc functions in English.</p></div>
</div>
<br>
  <div class="embedded">
<a name="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Example:</h3>
</div>
  <div class="embedded">
<a name="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">In Basic</h5>
</div>
  <div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
    oDoc.SetFormula("A1", "=A2")
    'Horizontal vector, partially empty
    oDoc.SetFormula("A1:F1", Array("=A2", "=B2", "=C2+10"))
    'D2 contains the formula "=H2"
    oDoc.SetFormula("A1:D2", "=E1")
  </code></pre></div>
  <div class="embedded">
<a name="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">In Python</h5>
</div>
  <div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
    myDoc.SetFormula("A1", "=A2")
    myDoc.SetFormula("A1:F1", ("=A2", "=B2", "=C2+10"))
    myDoc.SetFormula("A1:D2", "=E1")
  </code></pre></div>


<a name="SetValue"></a>
  
  <a name="bm_id901592231799526"></a>
      <meta itemprop="keywords" content="Calc service,SetValue">
  
  <h2 id="hd_id681592231799943" dir="auto">SetValue</h2>
  <p id="par_id601592231799489" class="paragraph" dir="auto">Stores the given value in the specified range. The size of the modified area is equal to the size of the target range.</p>
  <p id="par_id1001592233389953" class="paragraph" dir="auto">The method returns a string representing the modified area as a range of cells.</p>
  <div class="embedded">
<a name="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Syntax:</h3>
</div>
  <p id="par_id961621622582995" class="paragraph" dir="auto">
    <span class="input" data-tooltip="Click on text to copy to clipboard">svc.SetValue(targetrange: str, value: any): str</span>
  </p>
  <div class="embedded">
<a name="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parameters:</h3>
</div>
  <p id="par_id361592231799255" class="paragraph" dir="auto"><span class="emph">targetrange</span>: The range where to store the given value, as a string.</p>
  <p id="par_id461592232081985" class="paragraph" dir="auto"><span class="emph">value</span>: A scalar, a vector or an array with the new values for each cell of the range. The new values must be strings, numeric values or dates. Other types will cause the corresponding cells to be emptied.</p>
  <p id="par_id841592745785192" class="paragraph" dir="auto">The full range is updated and the remainder of the sheet is left unchanged. If the size of <span class="literal">value</span> is smaller than the size of <span class="literal">targetrange</span>, then the remaining cells will be emptied.</p>
  <p id="par_id191611776838396" class="paragraph" dir="auto">If the size of <span class="literal">value</span> is larger than the size of <span class="literal">targetrange</span>, then <span class="literal">value</span> is only partially copied until it fills the size of <span class="literal">targetrange</span>.</p>
  <p id="par_id71611776941663" class="paragraph" dir="auto">Vectors are expanded vertically, except if <span class="literal">targetrange</span> has a height of exactly 1 row.</p>
  <div class="embedded">
<a name="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Example:</h3>
</div>
  <div class="embedded">
<a name="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">In Basic</h5>
</div>
  <div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
    oDoc.SetValue("A1", 2)
    'Below the Value array is smaller than the TargetRange (remaining cells are emptied)
    oDoc.SetValue("A1:F1", Array(1, 2, 3))
    'Below the Value and TargetRange have the same size
    oDoc.SetValue("A1:D2", SF_Array.AppendRow(Array(1, 2, 3, 4), Array(5, 6, 7, 8)))
  </code></pre></div>
  <p id="par_id731621689592755" class="paragraph" dir="auto">If you want to fill a single row with values, you can use the <span class="literal">Offset</span> function. In the example below, consider that <span class="literal">arrData</span> is a one-dimensional array:</p>
  <div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
    Dim firstCell As String : firstCell = "A1"
    Dim lenArray As Integer : lenArray = UBound(arrData) - LBound(arrData) + 1
    Dim newRange As String : newRange = oDoc.Offset(firstCell, width = lenArray)
    oDoc.SetValue(newRange, arrData)
  </code></pre></div>
  <div class="embedded">
<a name="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">In Python</h5>
</div>
  <div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
    myDoc.SetValue("A1", 2)
    myDoc.SetValue("A1:F1", (1, 2, 3))
    myDoc.SetValue("A1:D2", ((1, 2, 3, 4), (5, 6, 7, 8)))
  </code></pre></div>
  <div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
    firstCell = "A1"
    newRange = doc.Offset(firstCell, width = len(arrData))
    doc.SetValue(newRange, arrData)
  </code></pre></div>


<a name="ShiftDown"></a>
  
  <a name="bm_id231593880376104"></a>
    <meta itemprop="keywords" content="Calc service,ShiftDown">
  
  <h2 id="hd_id191593880376667" dir="auto">ShiftDown</h2>
  <p id="par_id481593880373070" class="paragraph" dir="auto">Moves a given range of cells downwards by inserting empty rows. The current selection is not affected.</p>
  <p id="par_id801637929435655" class="paragraph" dir="auto">Depending on the value of the <span class="literal">wholerow</span> argument the inserted rows can either span the width of the specified range or span all columns in the row.</p>
  <p id="par_id711593880370247" class="paragraph" dir="auto">This method returns a string representing the new location of the initial range.</p>
  <div class="note">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/note.svg" alt="note" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id811637929284110" dir="auto">If the shifted range exceeds the sheet edges, then nothing happens.</p></div>
</div>
<br>
  <div class="embedded">
<a name="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Syntax:</h3>
</div>
  <p id="par_id701621623022250" class="paragraph" dir="auto">
    <span class="input" data-tooltip="Click on text to copy to clipboard">svc.ShiftDown(range: str, wholerow: bool = False, opt rows: int): str</span>
  </p>
  <div class="embedded">
<a name="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parameters:</h3>
</div>
  <p id="par_id891593880376123" class="paragraph" dir="auto"><span class="emph">range</span>: The range above which rows will be inserted, as a string.</p>
  <p id="par_id941593880376566" class="paragraph" dir="auto"><span class="emph">wholerow</span>: If set to <span class="literal">False</span> (default), then the width of the inserted rows will be the same as the width of the specified <span class="literal">range</span>. Otherwise, the inserted row will span all columns in the sheet.</p>
  <p id="par_id551593880373045" class="paragraph" dir="auto"><span class="emph">rows</span>: The number of rows to be inserted. The default value is the height of the original <span class="literal">range</span>. The number of rows must be a positive number.</p>
  <div class="embedded">
<a name="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Example:</h3>
</div>
  <div class="embedded">
<a name="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">In Basic</h5>
</div>
  <div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
    ' Moves the range "A3:D3" down by one row; affects only columns A to D
    oDoc.ShiftDown("A3:D3")
    ' The inserted row spans all columns in the sheet
    oDoc.ShiftDown("A3:D3", WholeRow := True)
    ' Moves the range "A3:D3" down by five rows
    oDoc.ShiftDown("A3:D3", Rows := 5)
    ' Moves the range "A3:D10" down by two rows and shows the new location of the original range
    Dim sNewRange as String
    sNewRange = oDoc.ShiftDown("A3:D10", Rows := 2)
    MsgBox sNewRange   ' $Sheet1.$A$5:$D$12
  </code></pre></div>
  <div class="embedded">
<a name="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">In Python</h5>
</div>
  <div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
    myDoc.ShiftDown("A3:D3")
    myDoc.ShiftDown("A3:D3", wholerow = True)
    myDoc.ShiftDown("A3:D3", rows = 5)
    sNewRange = myDoc.ShiftDown("A3:D10", rows = 2)
    bas = CreateScriptService("Basic")
    bas.MsgBox(sNewRange)
  </code></pre></div>


<a name="ShiftLeft"></a>
  
  <a name="bm_id231593880376547"></a>
    <meta itemprop="keywords" content="Calc service,ShiftLeft">
  
  <h2 id="hd_id191593880373026" dir="auto">ShiftLeft</h2>
  <p id="par_id481593880376255" class="paragraph" dir="auto">Deletes the leftmost columns of a given range and moves to the left all cells to the right of the affected range. The current selection is not affected.</p>
  <p id="par_id801637929460261" class="paragraph" dir="auto">Depending on the value of the <span class="literal">wholecolumn</span> argument the deleted columns can either span the height of the specified range or span all rows in the column.</p>
  <p id="par_id711593880371259" class="paragraph" dir="auto">This method returns a string representing the location of the remaining portion of the initial range. If all cells in the original range have been deleted, then an empty string is returned.</p>
  <div class="embedded">
<a name="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Syntax:</h3>
</div>
  <p id="par_id701621623026330" class="paragraph" dir="auto">
    <span class="input" data-tooltip="Click on text to copy to clipboard">svc.ShiftLeft(range: str, wholecolumn: bool = False, opt columns: int): str</span>
  </p>
  <div class="embedded">
<a name="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parameters:</h3>
</div>
  <p id="par_id891593880376205" class="paragraph" dir="auto"><span class="emph">range</span>: The range from which cells will be deleted, as a string.</p>
  <p id="par_id941593880356026" class="paragraph" dir="auto"><span class="emph">wholecolumn</span>: If set to <span class="literal">False</span> (default), then the height of the deleted columns will be the same as the height of the specified <span class="literal">range</span>. Otherwise, the deleted columns will span all rows in the sheet.</p>
  <p id="par_id551593880373306" class="paragraph" dir="auto"><span class="emph">columns</span>: The number of columns to be deleted from the specified <span class="literal">range</span>. The default value is the width of the original <span class="literal">range</span>, which is also the maximum value of this argument.</p>
  <div class="embedded">
<a name="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Example:</h3>
</div>
  <div class="embedded">
<a name="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">In Basic</h5>
</div>
  <div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
    ' Deletes the range "B3:B6"; moves left all cells to the right
    oDoc.ShiftLeft("B3:B6")
    ' Deletes the first column in the range "A3:D6"
    oDoc.ShiftLeft("A3:D6", Columns := 1)
    ' The deleted columns (A to D) spans all rows in the sheet
    oDoc.ShiftLeft("A3:D6", WholeColumn := True)
  </code></pre></div>
  <div class="embedded">
<a name="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">In Python</h5>
</div>
  <div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
    myDoc.ShiftLeft("B3:B6")
    myDoc.ShiftLeft("A3:D6", Columns = 1)
    myDoc.ShiftLeft("A3:D6", WholeColumn = True)
  </code></pre></div>


<a name="ShiftUp"></a>
  
  <a name="bm_id231593880376104"></a>
    <meta itemprop="keywords" content="Calc service,ShiftUp">
  
  <h2 id="hd_id191593880370547" dir="auto">ShiftUp</h2>
  <p id="par_id481593880373529" class="paragraph" dir="auto">Deletes the topmost rows of a given range and moves upwards all cells below the affected range. The current selection is not affected.</p>
  <p id="par_id801637929435361" class="paragraph" dir="auto">Depending on the value of the <span class="literal">wholerow</span> argument the deleted rows can either span the width of the specified range or span all columns in the row.</p>
  <p id="par_id711593880370299" class="paragraph" dir="auto">This method returns a string representing the location of the remaining portion of the initial range. If all cells in the original range have been deleted, then an empty string is returned.</p>
  <div class="embedded">
<a name="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Syntax:</h3>
</div>
  <p id="par_id701621623026380" class="paragraph" dir="auto">
    <span class="input" data-tooltip="Click on text to copy to clipboard">svc.ShiftUp(range: str, wholerow: bool = False, opt rows: int): str</span>
  </p>
  <div class="embedded">
<a name="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parameters:</h3>
</div>
  <p id="par_id891593880376583" class="paragraph" dir="auto"><span class="emph">range</span>: The range from which cells will be deleted, as a string.</p>
  <p id="par_id941593880300966" class="paragraph" dir="auto"><span class="emph">wholerow</span>: If set to <span class="literal">False</span> (default), then the width of the deleted rows will be the same as the width of the specified <span class="literal">range</span>. Otherwise, the deleted row will span all columns in the sheet.</p>
  <p id="par_id551593880373265" class="paragraph" dir="auto"><span class="emph">rows</span>: The number of rows to be deleted from the specified <span class="literal">range</span>. The default value is the height of the original <span class="literal">range</span>, which is also the maximum value of this argument.</p>
  <div class="embedded">
<a name="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Example:</h3>
</div>
  <div class="embedded">
<a name="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">In Basic</h5>
</div>
  <div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
    ' Deletes the range "A3:D3"; moves all cells below it by one row up
    oDoc.ShiftUp("A3:D3")
    ' Deletes the first row in the range "A3:D6"
    oDoc.ShiftUp("A3:D6", Rows := 1)
    ' The deleted rows spans all columns in the sheet
    oDoc.ShiftUp("A3:D6", WholeRow := True)
  </code></pre></div>
  <div class="embedded">
<a name="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">In Python</h5>
</div>
  <div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
    myDoc.ShiftUp("A3:D3")
    myDoc.ShiftUp("A3:D6", rows = 1)
    myDoc.ShiftUp("A3:D6", wholerow = True)
  </code></pre></div>


<a name="ShiftRight"></a>
  
  <a name="bm_id231593880376025"></a>
    <meta itemprop="keywords" content="Calc service,ShiftRight">
  
  <h2 id="hd_id191593880376547" dir="auto">ShiftRight</h2>
  <p id="par_id481593880372568" class="paragraph" dir="auto">Moves a given range of cells to the right by inserting empty columns. The current selection is not affected.</p>
  <p id="par_id801637929335255" class="paragraph" dir="auto">Depending on the value of the <span class="literal">wholecolumn</span> argument the inserted columns can either span the height of the specified range or span all rows in the column.</p>
  <p id="par_id711593880372560" class="paragraph" dir="auto">This method returns a string representing the new location of the initial range.</p>
  <div class="note">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/note.svg" alt="note" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id811637929283210" dir="auto">If the shifted range exceeds the sheet edges, then nothing happens.</p></div>
</div>
<br>
  <div class="embedded">
<a name="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Syntax:</h3>
</div>
  <p id="par_id701621623022269" class="paragraph" dir="auto">
    <span class="input" data-tooltip="Click on text to copy to clipboard">svc.ShiftRight(range: str, wholecolumn: bool = False, opt columns: int): str</span>
  </p>
  <div class="embedded">
<a name="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parameters:</h3>
</div>
  <p id="par_id891593880370543" class="paragraph" dir="auto"><span class="emph">range</span>: The range which will have empty columns inserted to its left, as a string.</p>
  <p id="par_id941593880373316" class="paragraph" dir="auto"><span class="emph">wholecolumn</span>: If set to <span class="literal">False</span> (default), then the height of the inserted columns will be the same as the height of the specified <span class="literal">range</span>. Otherwise, the inserted columns will span all rows in the sheet.</p>
  <p id="par_id5515938803791960" class="paragraph" dir="auto"><span class="emph">columns</span>: The number of columns to be inserted. The default value is the width of the original <span class="literal">range</span>.</p>
  <div class="embedded">
<a name="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Example:</h3>
</div>
  <div class="embedded">
<a name="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">In Basic</h5>
</div>
  <div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
    ' Moves the range "A3:A6" right by one column; affects only rows 3 to 6
    oDoc.ShiftRight("A3:A6")
    ' Moves the range "A3:A6" right by five columns
    oDoc.ShiftRight("A3:A6", Columns := 5)
    ' The inserted column spans all rows in the sheet
    oDoc.ShiftRight("A3:A6", WholeColumn := True)
  </code></pre></div>
  <div class="embedded">
<a name="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">In Python</h5>
</div>
  <div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
    myDoc.ShiftRight("A3:A6")
    myDoc.ShiftRight("A3:A6", columns = 5)
    myDoc.ShiftRight("A3:A6", wholecolumn = True)
  </code></pre></div>


<a name="SortRange"></a>
  
  <a name="bm_id531595692394747"></a>
      <meta itemprop="keywords" content="Calc service,SortRange">
  
  <h2 id="hd_id71595692394823" dir="auto">SortRange</h2>
  <p id="par_id141595692394382" class="paragraph" dir="auto">Sort the given range on any number of columns/rows. The sorting order may vary by column/row. If the number of sort keys is &gt; 3 then the range is sorted several times, by groups of 3 keys, starting from the last key. It returns a string representing the modified range of cells. The size of the modified area is fully determined by the size of the source area.</p>
  <div class="embedded">
<a name="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Syntax:</h3>
</div>
  <p id="par_id871621623279253" class="paragraph" dir="auto">
    <span class="input" data-tooltip="Click on text to copy to clipboard">svc.SortRange(range: str, sortkeys: any, sortorder: any = "ASC", destinationcell: str = "", containsheader: bool = False, casesensitive: bool = False, sortcolumns: bool = False): str</span>
  </p>
  <div class="embedded">
<a name="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parameters:</h3>
</div>
  <p id="par_id171595692394598" class="paragraph" dir="auto"><span class="emph">range</span>: The range to be sorted, as a string.</p>
  <p id="par_id171595692814163" class="paragraph" dir="auto"><span class="emph">sortkeys</span>: A scalar (if 1 column/row) or an array of column/row numbers starting from 1.</p>
  <p id="par_id421595692962095" class="paragraph" dir="auto"><span class="emph">sortorder</span>: A scalar or an array of strings containing the values "ASC" (ascending), "DESC" (descending). Each item is paired with the corresponding item in <span class="literal">sortkeys</span>. If the <span class="literal">sortorder</span> array is shorter than <span class="literal">sortkeys</span>, the remaining keys are sorted in ascending order.</p>
  <p id="par_id361595692394604" class="paragraph" dir="auto"><span class="emph">destinationcell</span>: The destination cell of the sorted range of cells, as a string. If a range is given, only its top-left cell is considered. By default the source Range is overwritten.</p>
  <p id="par_id441595693011034" class="paragraph" dir="auto"><span class="emph">containsheader</span>: When <span class="literal">True</span>, the first row/column is not sorted.</p>
  <p id="par_id241595693169032" class="paragraph" dir="auto"><span class="emph">casesensitive</span>: Only for string comparisons. Default = <span class="literal">False</span></p>
  <p id="par_id1001595693326226" class="paragraph" dir="auto"><span class="emph">sortcolumns</span>: When <span class="literal">True</span>, the columns are sorted from left to right. Default = <span class="literal">False</span> : rows are sorted from top to bottom.</p>
  <div class="embedded">
<a name="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Example:</h3>
</div>
  <div class="embedded">
<a name="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">In Basic</h5>
</div>
  <div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
    'Sort range based on columns A (ascending) and C (descending)
    oDoc.SortRange("A2:J200", Array(1, 3), Array("ASC", "DESC"), CaseSensitive := True)
  </code></pre></div>
  <div class="embedded">
<a name="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">In Python</h5>
</div>
  <div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-python line-numbers">
    myDoc.SortRange("A2:J200", (1, 3), ("ASC", "DESC"), casesensitive = True)
  </code></pre></div>


  <div class="embedded">
<a name="SF_InternalUse"></a>
      <div class="warning">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/warning.svg" alt="warning" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id851506659675843" dir="auto">All <span class="literal">ScriptForge</span> Basic routines or identifiers that are prefixed with an underscore character "_" are reserved for internal use. They are not meant be used in Basic macros or Python scripts.</p></div>
</div>
<br>
    </div>
  <a name="relatedtopics"></a><div class="relatedtopics">
<p class="related" itemprop="mentions" dir="auto"><a name="related"></a><span class="emph">Related Topics</span>
</p>
<div class="relatedbody" itemprop="mentions">
    <div class="embedded"><p class="embedded" dir="auto"><a target="_top" href="en-US/text/sbasic/shared/03/sf_chart.html"><span class="literal">SFDocuments</span>.<span class="literal">Chart</span> service</a></p></div>
    <div class="embedded"><p class="embedded" dir="auto"><a target="_top" href="en-US/text/sbasic/shared/03/sf_document.html"><span class="literal">SFDocuments</span>.<span class="literal">Document</span> service</a></p></div>
    <div class="embedded"><p class="embedded" dir="auto"><a target="_top" href="en-US/text/sbasic/shared/03/sf_ui.html"><span class="literal">ScriptForge</span>.<span class="literal">UI</span> service</a></p></div>
  </div>
</div>
</div>
<div id="DonationFrame"></div>
<footer><div id="DEBUG" class="debug">
<h3 class="bug">Help content debug info:</h3>
<p dir="auto">This page is: <a href="https://opengrok.libreoffice.org/xref/help/source/text/sbasic/shared/03/sf_calc.xhp" target="_blank">/text/sbasic/shared/03/sf_calc.xhp</a></p>
<p dir="auto">Title is: SFDocuments.Calc service</p>
<p id="bm_module" dir="auto"></p>
<p id="bm_system" dir="auto"></p>
<p id="bm_HID" dir="auto"></p>
</div></footer>
</body>
</html>

Youez - 2016 - github.com/yon3zu
LinuXploit