Add document for sheet properties

This commit is contained in:
El Mau 2022-03-14 23:21:25 -06:00
parent 4bf03e582d
commit ab28969dce
2 changed files with 45 additions and 14 deletions

View File

@ -266,11 +266,11 @@ Sort
Name
^^^^
* Name visible by the user.
Name visible by the user.
.. code-block:: python
sheet = app.active_sheet
sheet = doc.active
app.msgbox(sheet.name)
sheet.name = 'NewName'
app.msgbox(sheet.name)
@ -279,11 +279,11 @@ Name
Code name
^^^^^^^^^
* Name only accessible by code.
Only accessible by code.
.. code-block:: python
sheet = app.active_sheet
sheet = doc.active
app.msgbox(sheet.code_name)
sheet.code_name = 'my_name'
app.msgbox(sheet.code_name)
@ -292,11 +292,11 @@ Code name
Visible
^^^^^^^
* Apply only with spreadsheet with two or more sheets.
Apply only with spreadsheet with two or more sheets.
.. code-block:: python
sheet = app.active_sheet
sheet = doc.active
app.msgbox(sheet.visible)
sheet.visible = not sheet.visible
app.msgbox(sheet.visible)
@ -306,11 +306,11 @@ Visible
Is protected
^^^^^^^^^^^^
* If sheet is protected with password.
If sheet is protected with password.
.. code-block:: python
sheet = app.active_sheet
sheet = doc.active
app.msgbox(sheet.is_protected)
@ -319,7 +319,7 @@ Set password
.. code-block:: python
sheet = app.active_sheet
sheet = doc.active
sheet.password = 'letmein'
app.msgbox(sheet.is_protected)
@ -329,7 +329,7 @@ Remove password
.. code-block:: python
sheet = app.active_sheet
sheet = doc.active
sheet.password = 'letmein'
app.msgbox(sheet.is_protected)
@ -342,7 +342,7 @@ Tab color
.. code-block:: python
sheet = app.active_sheet
sheet = doc.active
app.msgbox(sheet.color)
sheet.color = 'red'
@ -359,6 +359,7 @@ Document parent
.. code-block:: python
doc = sheet.doc
app.msgbox(doc.title)
Activate
@ -367,11 +368,15 @@ Activate
.. code-block:: python
doc = app.active
# Get last sheet
sheet = doc[-1]
# Activate from doc
doc.activate(sheet)
# Activate from sheet
sheet.activate()
# Activate from doc
doc.activate(doc[1])
# Activate by name
doc.activate('Sheet3')

View File

@ -3435,10 +3435,32 @@ class LOCalcSheet(object):
def visible(self, value):
self._obj.IsVisible = value
@property
def color(self):
return self._obj.TabColor
@color.setter
def color(self, value):
self._obj.TabColor = Color()(value)
@property
def is_protected(self):
return self._obj.isProtected()
@property
def password(self):
return ''
@password.setter
def password(self, value):
self.obj.protect(value)
def unprotect(self, value):
try:
self.obj.unprotect(value)
return True
except:
pass
return False
def move(self, pos: int=-1):
index = pos
if pos < 0:
@ -3466,6 +3488,10 @@ class LOCalcSheet(object):
sheet = doc.copy_from(self.doc, self.name, new_name, index)
return sheet
def activate(self):
self.doc.activate(self.obj)
return
class LOCalcRange(object):
CELL = 'ScCellObj'