Skip to main content

Метод Table.setProtection

Метод устанавливает защиту от изменений на лист табличного документа (см. Защита листа табличного документа).

Вызов​


setProtection(tableProtectionProperties, password)

Параметры​

  • tableProtectionProperties: параметры защиты листа, тип TableProtectionProperties;
  • password: (необязательный) пароль для установки защиты, тип string.

Пример​


tableProps = myOfficeSDK.TableProtectionProperties()
tableProps.deleteColumns = False
tableProps.deleteRows = False
tableProps.filterData = True
tableProps.formatCells = True
tableProps.formatColumns = True
tableProps.formatRows = True
tableProps.insertAndEditObjects = False
tableProps.insertAndEditPivotTables = False
tableProps.insertColumns = False
tableProps.insertLinks = True
tableProps.insertRows = False
tableProps.selectProtectedCells = True
tableProps.sortData = True

firstSheet = document.getBlocks().getTable(0)
firstSheet.setProtection(tableProps, "password")

Метод setProtectionProperties() объектов Cell и CellRange позволяет задать параметры защиты для ячеек (например, разрешить редактирование определенных ячеек в документе перед установкой защиты).

Если метод setProtection() применяется к уже защищенному листу, возникает исключение SpreadsheetProtectionError.