Sheets ~~~~~~ Active sheet ^^^^^^^^^^^^ .. code-block:: python sheet = app.active_sheet app.msgbox(sheet.name) # or doc = app.active sheet = doc.active Get by index ^^^^^^^^^^^^ .. code-block:: python doc = app.active sheet = doc[0] app.msgbox(sheet.name) Get by name ^^^^^^^^^^^ .. code-block:: python doc = app.active sheet = doc['Sheet1'] app.msgbox(sheet.name) Contains ^^^^^^^^ .. code-block:: python doc = app.active app.msgbox('Sheet1' in doc) Get tuple with all names ^^^^^^^^^^^^^^^^^^^^^^^^ .. code-block:: python doc = app.active app.msgbox(doc.names) Count ^^^^^ .. code-block:: python doc = app.active app.msgbox(len(doc)) New ^^^ * Always validate if new name not exists. .. code-block:: python doc = app.active sheet = doc.new_sheet() # CAUTION: If 'NewSheet' exists, reset it to clean sheet. doc['NewSheet'] = sheet # ~ or sheet = doc.insert('NewSheet2') * Insert multiple, get last insert. .. code-block:: python names = ('One', 'Two', 'Three') sheet = doc.insert(names) Move ^^^^ * Move by object to last position. .. code-block:: python sheet = doc[0] doc.move(sheet) * Move by name to last position. .. code-block:: python doc.move('Sheet1') * Move to position. .. code-block:: python sheet = doc[0] doc.move(sheet, 2) * Move from sheet .. code-block:: python sheet = app.active_sheet sheet.move() * Move to position. .. code-block:: python sheet = app.active_sheet sheet.move(2) Remove ^^^^^^ * Remove by object. .. code-block:: python sheet = doc[0] doc.remove(sheet) * Remove by name. .. code-block:: python doc.remove('One') * Remove from sheet. .. code-block:: python sheet = app.active_sheet sheet.remove() Copy ^^^^ * Copy inside the same spreadsheet. * By object .. code-block:: python sheet = doc[0] doc.copy_sheet(sheet, 'OtherSheet') * By name .. code-block:: python doc.copy_sheet('Sheet1', 'Sheet2') * From sheet .. code-block:: python sheet = app.active_sheet sheet.copy(sheet.name + '_2') Copy from ^^^^^^^^^ * Copy sheet from one spreadsheet to other. .. code-block:: python doc = app.active doc_source = app.docs['Contacts.ods'] name_source = 'Names' name_target = 'Names' position = 0 doc.copy_from(doc_source, name_source, name_target, position) Copy to ^^^^^^^ * Copy from sheet with the same name .. code-block:: python doc = app.docs.new() sheet = app.active_sheet sheet.copy_to(doc) * Used new name .. code-block:: python doc = app.docs.new() sheet = app.active_sheet sheet.copy_to(doc, 'NewName') Sort ^^^^ * Sort sheets by names. .. code-block:: python doc = app.active doc.sort() Name ^^^^ * Name visible by the user. .. code-block:: python sheet = app.active_sheet app.msgbox(sheet.name) sheet.name = 'NewName' app.msgbox(sheet.name) Code name ^^^^^^^^^ * Name only accessible by code. .. code-block:: python sheet = app.active_sheet app.msgbox(sheet.code_name) sheet.code_name = 'my_name' app.msgbox(sheet.code_name) Visible ^^^^^^^ * Apply only with spreadsheet with two or more sheets. .. code-block:: python sheet = app.active_sheet app.msgbox(sheet.visible) sheet.visible = not sheet.visible app.msgbox(sheet.visible) sheet.visible = not sheet.visible Is protected ^^^^^^^^^^^^ * If sheet is protected with password. .. code-block:: python sheet = app.active_sheet app.msgbox(sheet.is_protected) Set password ^^^^^^^^^^^^ .. code-block:: python sheet = app.active_sheet sheet.password = 'letmein' app.msgbox(sheet.is_protected) Remove password ^^^^^^^^^^^^^^^ .. code-block:: python sheet = app.active_sheet sheet.password = 'letmein' app.msgbox(sheet.is_protected) sheet.unprotect('letmein') app.msgbox(sheet.is_protected) Tab color ^^^^^^^^^ .. code-block:: python sheet = app.active_sheet app.msgbox(sheet.color) sheet.color = 'red' app.msgbox(sheet.color) # RGB sheet.color = (125, 200, 10) app.msgbox(sheet.color) Document parent ^^^^^^^^^^^^^^^ .. code-block:: python doc = sheet.doc Activate ^^^^^^^^ .. code-block:: python doc = app.active # Get last sheet sheet = doc[-1] # Activate from doc doc.activate(sheet) # Activate from sheet sheet.activate()