[]
        
(Showing Draft Content)

IProtectionSettings

Interface IProtectionSettings


public interface IProtectionSettings
Represents the various types of protection options available for a worksheet.

Use this interface to configure which operations remain available on a protected worksheet, such as inserting or deleting rows and columns, filtering, sorting, or editing scenarios. The setting action will take effect only if the worksheet is under protection.


 worksheet.setProtection(true);
 IProtectionSettings protectionSettings = worksheet.getProtectionSettings();
 protectionSettings.setAllowDeletingColumns(true);
 protectionSettings.setAllowDeletingRows(true);
 
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Loads worksheet protection settings from a JSON string into this object.
    boolean
    Gets whether the deletion of columns is allowed on a protected worksheet.
    boolean
    Gets whether the deletion of rows is allowed on a protected worksheet.
    boolean
    Gets whether the user is allowed to edit scenarios on a protected worksheet.
    boolean
    Gets whether the user is allowed to make use of an AutoFilter that was created before the sheet was protected.
    boolean
    Gets whether the formatting of cells is allowed on a protected worksheet.
    boolean
    Gets whether the formatting of columns is allowed on a protected worksheet.
    boolean
    Gets whether the formatting of rows is allowed on a protected worksheet.
    boolean
    Gets whether the insertion of columns is allowed on a protected worksheet.
    boolean
    Gets whether the insertion of hyperlinks is allowed on a protected worksheet.
    boolean
    Gets whether the insertion of rows is allowed on a protected worksheet.
    boolean
    Gets whether the sorting option is allowed on a protected worksheet.
    boolean
    Gets whether the user is allowed to use drawing objects on a protected worksheet.
    boolean
    Gets whether the user is allowed to use pivot tables on a protected worksheet.
    void
    setAllowDeletingColumns(boolean value)
    Sets whether the deletion of columns is allowed on a protected worksheet.
    void
    setAllowDeletingRows(boolean value)
    Sets whether the deletion of rows is allowed on a protected worksheet.
    void
    setAllowEditingScenarios(boolean value)
    Sets whether the user is allowed to edit scenarios on a protected worksheet.
    void
    setAllowFiltering(boolean value)
    Sets whether the user is allowed to make use of an AutoFilter that was created before the sheet was protected.
    void
    setAllowFormattingCells(boolean value)
    Sets whether the formatting of cells is allowed on a protected worksheet.
    void
    Sets whether the formatting of columns is allowed on a protected worksheet.
    void
    setAllowFormattingRows(boolean value)
    Sets whether the formatting of rows is allowed on a protected worksheet.
    void
    setAllowInsertingColumns(boolean value)
    Sets whether the insertion of columns is allowed on a protected worksheet.
    void
    Sets whether the insertion of hyperlinks is allowed on a protected worksheet.
    void
    setAllowInsertingRows(boolean value)
    Sets whether the insertion of rows is allowed on a protected worksheet.
    void
    setAllowSorting(boolean value)
    Sets whether the sorting option is allowed on a protected worksheet.
    void
    setAllowUsingObjects(boolean value)
    Sets whether the user is allowed to use drawing objects on a protected worksheet.
    void
    setAllowUsingPivotTables(boolean value)
    Sets whether the user is allowed to use pivot tables on a protected worksheet.
    Serializes the current worksheet protection settings to a JSON string.
  • Method Details

    • getAllowDeletingColumns

      boolean getAllowDeletingColumns()
      Gets whether the deletion of columns is allowed on a protected worksheet.

      This setting is meaningful only when worksheet protection is enabled.

      
       worksheet.setProtection(true);
       IProtectionSettings protectionSettings = worksheet.getProtectionSettings();
       protectionSettings.setAllowDeletingColumns(true);
       boolean allowDeletingColumns = protectionSettings.getAllowDeletingColumns();
       
      Returns:
      true if deleting columns is allowed on the protected worksheet; otherwise, false.
    • setAllowDeletingColumns

      void setAllowDeletingColumns(boolean value)
      Sets whether the deletion of columns is allowed on a protected worksheet.

      This setting is meaningful only when worksheet protection is enabled.

      
       worksheet.setProtection(true);
       IProtectionSettings protectionSettings = worksheet.getProtectionSettings();
       protectionSettings.setAllowDeletingColumns(true);
       
      Parameters:
      value - true if deleting columns is allowed on the protected worksheet; otherwise, false.
    • getAllowDeletingRows

      boolean getAllowDeletingRows()
      Gets whether the deletion of rows is allowed on a protected worksheet.

      This setting is meaningful only when worksheet protection is enabled.

      
       worksheet.setProtection(true);
       IProtectionSettings protectionSettings = worksheet.getProtectionSettings();
       protectionSettings.setAllowDeletingRows(true);
       boolean allowDeletingRows = protectionSettings.getAllowDeletingRows();
       
      Returns:
      true if deleting rows is allowed on the protected worksheet; otherwise, false.
    • setAllowDeletingRows

      void setAllowDeletingRows(boolean value)
      Sets whether the deletion of rows is allowed on a protected worksheet.

      This setting is meaningful only when worksheet protection is enabled.

      
       worksheet.setProtection(true);
       IProtectionSettings protectionSettings = worksheet.getProtectionSettings();
       protectionSettings.setAllowDeletingRows(true);
       
      Parameters:
      value - true if deleting rows is allowed on the protected worksheet; otherwise, false.
    • getAllowFiltering

      boolean getAllowFiltering()
      Gets whether the user is allowed to make use of an AutoFilter that was created before the sheet was protected.

      This property indicates whether filtering remains available after worksheet protection is enabled.

      
       worksheet.setProtection(true);
       IProtectionSettings protectionSettings = worksheet.getProtectionSettings();
       protectionSettings.setAllowFiltering(true);
       boolean allowFiltering = protectionSettings.getAllowFiltering();
       
      Returns:
      true if the user can use an AutoFilter that was created before the worksheet was protected; otherwise, false.
    • setAllowFiltering

      void setAllowFiltering(boolean value)
      Sets whether the user is allowed to make use of an AutoFilter that was created before the sheet was protected.

      This property indicates whether filtering remains available after worksheet protection is enabled.

      
       worksheet.setProtection(true);
       IProtectionSettings protectionSettings = worksheet.getProtectionSettings();
       protectionSettings.setAllowFiltering(true);
       
      Parameters:
      value - true if the user can use an AutoFilter that was created before the worksheet was protected; otherwise, false.
    • getAllowFormattingCells

      boolean getAllowFormattingCells()
      Gets whether the formatting of cells is allowed on a protected worksheet.

      This setting is meaningful only when worksheet protection is enabled.

      
       worksheet.setProtection(true);
       IProtectionSettings protectionSettings = worksheet.getProtectionSettings();
       protectionSettings.setAllowFormattingCells(true);
       boolean allowFormattingCells = protectionSettings.getAllowFormattingCells();
       
      Returns:
      true if formatting cells is allowed on the protected worksheet; otherwise, false.
    • setAllowFormattingCells

      void setAllowFormattingCells(boolean value)
      Sets whether the formatting of cells is allowed on a protected worksheet.

      This setting is meaningful only when worksheet protection is enabled.

      
       worksheet.setProtection(true);
       IProtectionSettings protectionSettings = worksheet.getProtectionSettings();
       protectionSettings.setAllowFormattingCells(true);
       
      Parameters:
      value - true if formatting cells is allowed on the protected worksheet; otherwise, false.
    • getAllowFormattingColumns

      boolean getAllowFormattingColumns()
      Gets whether the formatting of columns is allowed on a protected worksheet.

      This setting is meaningful only when worksheet protection is enabled.

      
       worksheet.setProtection(true);
       IProtectionSettings protectionSettings = worksheet.getProtectionSettings();
       protectionSettings.setAllowFormattingColumns(true);
       boolean allowFormattingColumns = protectionSettings.getAllowFormattingColumns();
       
      Returns:
      true if formatting columns is allowed on the protected worksheet; otherwise, false.
    • setAllowFormattingColumns

      void setAllowFormattingColumns(boolean value)
      Sets whether the formatting of columns is allowed on a protected worksheet.

      This setting is meaningful only when worksheet protection is enabled.

      
       worksheet.setProtection(true);
       IProtectionSettings protectionSettings = worksheet.getProtectionSettings();
       protectionSettings.setAllowFormattingColumns(true);
       
      Parameters:
      value - true if formatting columns is allowed on the protected worksheet; otherwise, false.
    • getAllowFormattingRows

      boolean getAllowFormattingRows()
      Gets whether the formatting of rows is allowed on a protected worksheet.
      
       worksheet.setProtection(true);
       IProtectionSettings protectionSettings = worksheet.getProtectionSettings();
       protectionSettings.setAllowFormattingRows(true);
       boolean allowFormattingRows = protectionSettings.getAllowFormattingRows();
       
      Returns:
      true if formatting rows is allowed on a protected worksheet; otherwise, false.
    • setAllowFormattingRows

      void setAllowFormattingRows(boolean value)
      Sets whether the formatting of rows is allowed on a protected worksheet.
      
       worksheet.setProtection(true);
       IProtectionSettings protectionSettings = worksheet.getProtectionSettings();
       protectionSettings.setAllowFormattingRows(true);
       
      Parameters:
      value - true if formatting rows is allowed on a protected worksheet; otherwise, false.
    • getAllowInsertingColumns

      boolean getAllowInsertingColumns()
      Gets whether the insertion of columns is allowed on a protected worksheet.

      This property determines whether users can insert columns while worksheet protection is enabled.

      
       worksheet.setProtection(true);
       IProtectionSettings protectionSettings = worksheet.getProtectionSettings();
       protectionSettings.setAllowInsertingColumns(true);
       boolean allowInsertingColumns = protectionSettings.getAllowInsertingColumns();
       
      Returns:
      true if inserting columns is allowed on a protected worksheet; otherwise, false.
    • setAllowInsertingColumns

      void setAllowInsertingColumns(boolean value)
      Sets whether the insertion of columns is allowed on a protected worksheet.

      This property determines whether users can insert columns while worksheet protection is enabled.

      
       worksheet.setProtection(true);
       IProtectionSettings protectionSettings = worksheet.getProtectionSettings();
       protectionSettings.setAllowInsertingColumns(true);
       
      Parameters:
      value - true if inserting columns is allowed on a protected worksheet; otherwise, false.
    • getAllowInsertingRows

      boolean getAllowInsertingRows()
      Gets whether the insertion of rows is allowed on a protected worksheet.

      This property determines whether users can insert rows while worksheet protection is enabled.

      
       worksheet.setProtection(true);
       IProtectionSettings protectionSettings = worksheet.getProtectionSettings();
       protectionSettings.setAllowInsertingRows(true);
       boolean allowInsertingRows = protectionSettings.getAllowInsertingRows();
       
      Returns:
      true if inserting rows is allowed on a protected worksheet; otherwise, false.
    • setAllowInsertingRows

      void setAllowInsertingRows(boolean value)
      Sets whether the insertion of rows is allowed on a protected worksheet.

      This property determines whether users can insert rows while worksheet protection is enabled.

      
       worksheet.setProtection(true);
       IProtectionSettings protectionSettings = worksheet.getProtectionSettings();
       protectionSettings.setAllowInsertingRows(true);
       
      Parameters:
      value - true if inserting rows is allowed on a protected worksheet; otherwise, false.
    • getAllowInsertingHyperlinks

      boolean getAllowInsertingHyperlinks()
      Gets whether the insertion of hyperlinks is allowed on a protected worksheet.

      This property applies when worksheet protection is enabled.

      
       worksheet.setProtection(true);
       IProtectionSettings protectionSettings = worksheet.getProtectionSettings();
       protectionSettings.setAllowInsertingHyperlinks(true);
       boolean allowInsertingHyperlinks = protectionSettings.getAllowInsertingHyperlinks();
       
      Returns:
      true if inserting hyperlinks is allowed on the protected worksheet; otherwise, false.
    • setAllowInsertingHyperlinks

      void setAllowInsertingHyperlinks(boolean value)
      Sets whether the insertion of hyperlinks is allowed on a protected worksheet.

      This property applies when worksheet protection is enabled.

      
       worksheet.setProtection(true);
       IProtectionSettings protectionSettings = worksheet.getProtectionSettings();
       protectionSettings.setAllowInsertingHyperlinks(true);
       
      Parameters:
      value - true if inserting hyperlinks is allowed on the protected worksheet; otherwise, false.
    • getAllowSorting

      boolean getAllowSorting()
      Gets whether the sorting option is allowed on a protected worksheet.

      This property indicates whether users can sort ranges when worksheet protection is enabled.

      
       worksheet.setProtection(true);
       IProtectionSettings protectionSettings = worksheet.getProtectionSettings();
       protectionSettings.setAllowSorting(true);
       boolean allowSorting = protectionSettings.getAllowSorting();
       
      Returns:
      true if sorting is allowed on the protected worksheet; otherwise, false.
    • setAllowSorting

      void setAllowSorting(boolean value)
      Sets whether the sorting option is allowed on a protected worksheet.

      This property indicates whether users can sort ranges when worksheet protection is enabled.

      
       worksheet.setProtection(true);
       IProtectionSettings protectionSettings = worksheet.getProtectionSettings();
       protectionSettings.setAllowSorting(true);
       
      Parameters:
      value - true if sorting is allowed on the protected worksheet; otherwise, false.
    • getAllowUsingPivotTables

      boolean getAllowUsingPivotTables()
      Gets whether the user is allowed to use pivot tables on a protected worksheet.

      This property indicates whether users can work with pivot tables when worksheet protection is enabled.

      
       worksheet.setProtection(true);
       IProtectionSettings protectionSettings = worksheet.getProtectionSettings();
       protectionSettings.setAllowUsingPivotTables(true);
       boolean allowUsingPivotTables = protectionSettings.getAllowUsingPivotTables();
       
      Returns:
      true if using pivot tables is allowed on the protected worksheet; otherwise, false.
    • setAllowUsingPivotTables

      void setAllowUsingPivotTables(boolean value)
      Sets whether the user is allowed to use pivot tables on a protected worksheet.

      This property indicates whether users can work with pivot tables when worksheet protection is enabled.

      
       worksheet.setProtection(true);
       IProtectionSettings protectionSettings = worksheet.getProtectionSettings();
       protectionSettings.setAllowUsingPivotTables(true);
       
      Parameters:
      value - true if using pivot tables is allowed on the protected worksheet; otherwise, false.
    • getAllowUsingObjects

      boolean getAllowUsingObjects()
      Gets whether the user is allowed to use drawing objects on a protected worksheet.

      Drawing objects include shapes, charts, pictures, text boxes, and controls. This setting is meaningful only when worksheet protection is enabled.

      
       worksheet.setProtection(true);
       IProtectionSettings protectionSettings = worksheet.getProtectionSettings();
       protectionSettings.setAllowUsingObjects(true);
       boolean allowUsingObjects = protectionSettings.getAllowUsingObjects();
       
      Returns:
      true if the user is allowed to select and edit drawing objects on the protected worksheet; otherwise, false.
    • setAllowUsingObjects

      void setAllowUsingObjects(boolean value)
      Sets whether the user is allowed to use drawing objects on a protected worksheet.

      Drawing objects include shapes, charts, pictures, text boxes, and controls. This setting is meaningful only when worksheet protection is enabled.

      
       worksheet.setProtection(true);
       IProtectionSettings protectionSettings = worksheet.getProtectionSettings();
       protectionSettings.setAllowUsingObjects(true);
       
      Parameters:
      value - true to allow the user to select and edit drawing objects on the protected worksheet; otherwise, false.
    • getAllowEditingScenarios

      boolean getAllowEditingScenarios()
      Gets whether the user is allowed to edit scenarios on a protected worksheet. The default value is false.

      This property indicates whether scenario editing is permitted when worksheet protection is enabled. Use setAllowEditingScenarios(boolean) to change this setting.

      
       worksheet.setProtection(true);
       IProtectionSettings protectionSettings = worksheet.getProtectionSettings();
       protectionSettings.setAllowEditingScenarios(true);
       boolean allowEditingScenarios = protectionSettings.getAllowEditingScenarios();
       
      Returns:
      true if the user is allowed to edit scenarios on a protected worksheet; otherwise, false. The default value is false.
    • setAllowEditingScenarios

      void setAllowEditingScenarios(boolean value)
      Sets whether the user is allowed to edit scenarios on a protected worksheet. The default value is false.
      
       worksheet.setProtection(true);
       IProtectionSettings protectionSettings = worksheet.getProtectionSettings();
       protectionSettings.setAllowEditingScenarios(true);
       
      Parameters:
      value - true if the user is allowed to edit scenarios on a protected worksheet; otherwise, false. The default value is false.
    • fromJson

      void fromJson(String json)
      Loads worksheet protection settings from a JSON string into this object.

      Use this method to update the current IProtectionSettings instance from a JSON string produced by toJson(). The configured settings take effect only when the worksheet is protected.

      
       IProtectionSettings source = worksheet.getProtectionSettings();
       source.setAllowSorting(true);
       String json = source.toJson();
       IWorksheet targetSheet = workbook.getWorksheets().add();
       IProtectionSettings target = targetSheet.getProtectionSettings();
       target.fromJson(json);
       targetSheet.setProtection(true);
       
      Parameters:
      json - The JSON string representing worksheet protection settings.
    • toJson

      String toJson()
      Serializes the current worksheet protection settings to a JSON string.

      Use this method to serialize the current IProtectionSettings values so that they can be reused with fromJson(String). The serialized content represents worksheet protection options.

      
       worksheet.setProtection(true);
       IProtectionSettings protectionSettings = worksheet.getProtectionSettings();
       protectionSettings.setAllowDeletingColumns(true);
       String json = protectionSettings.toJson();
       
      Returns:
      The JSON string representing the current worksheet protection settings.