[Libreoffice-commits] core.git: scripting/examples

Tor Lillqvist tml at collabora.com
Wed Mar 28 13:58:40 UTC 2018


 scripting/examples/python/NamedRanges.py |   11 +++++++++++
 1 file changed, 11 insertions(+)

New commits:
commit f21e341d0fbfb39f7d5d976f89f00f844e201576
Author: Tor Lillqvist <tml at collabora.com>
Date:   Wed Mar 28 16:52:28 2018 +0300

    Add DeleteNamedRange function
    
    Change-Id: I081614cb34aee704c9162f58c78dbaa6a350d30b

diff --git a/scripting/examples/python/NamedRanges.py b/scripting/examples/python/NamedRanges.py
index abdef141f397..812cabb583e0 100644
--- a/scripting/examples/python/NamedRanges.py
+++ b/scripting/examples/python/NamedRanges.py
@@ -35,3 +35,14 @@ def DefineNamedRange(sheet, x0, y0, width, height, name):
     position.Row = 0
     model.NamedRanges.addNewByName(name, content, position, 0)
     return None
+
+def DeleteNamedRange(name):
+    try:
+        desktop = XSCRIPTCONTEXT.getDesktop()
+        model = desktop.getCurrentComponent()
+        model.NamedRanges.removeByName(name)
+    except Exception as e:
+        print("Caught Exception: " + str(e))
+        tb = e.__traceback__
+        traceback.print_tb(tb)
+    return None


More information about the Libreoffice-commits mailing list