Table of Contents

TProtection Class

Encryption data for an Excel sheet.

Syntax

Namespace: FlexCel.Core

public sealed class TProtection

Methods

Name Description
AddProtectedRange Adds a protected range to the sheet.
AssignedOnPassword Returns true is there is at least one event handler attached to then OnPassword event.
ClearProtectedRanges Removes all protected ranges in the sheet.
DeleteProtectedRange Deletes an existing protected range.
GetProtectedRange Returns a protected range.
GetSharedWorkbook​Protection​Options Reads the protection options for the change history.
GetSheetProtection​Options Return the sheet protection options for the file.
GetWorkbookProtection​Options Reads the Workbook protection options for a file.
RemoveAllOnPassword​Events Removes all event handlers attached to OnPassword.
SetModifyPassword Sets the password for modifying the file. It won't encrypt the file, it just won't let Excel save the file. On Excel goto Options->Security to check it.
Note that you can only set it, there is no way to retrieve an existing password.
SetSharedWorkbook​Protection Protects the change history from being removed. On Excel goto Protect->Protect Shared Workbook to check it.
SetSharedWorkbook​Protection​Options Sets the change history protection options for a file.
SetSheetProtection Protects a sheet. On Excel goto Protect->Sheet to check it.
SetSheetProtection​Options Sets the sheet protection options for the file.
SetWorkbookProtection Protects the workbook. On Excel goto Protect->Workbook to check it.
SetWorkbookProtection​Options Sets the workbook protection options for a file.

Properties

Name Description
EncryptionAlgorithm​Xlsx Encryption algorithm for xlsx files.
EncryptionType Encryption mode for xls files .
HasModifyPassword Returns true if the file has a password to modify.
HasSharedWorkbook​Password Returns true if the change history is protected with a password.
HasSheetPassword Returns true if the active sheet is protected with a password.
HasWorkbookPassword Returns true if the workbook is protected with a password.
OpenPassword Sets the password to open the file. When set, the file will be encrypted. On Excel go to Options->Security to check it.
Set this to null to clear it.
ProtectedRangeCount Returns a the count of protected ranges in the active sheet.
RecommendReadOnly Returns true if the file is recommended to open read-only.
WriteAccess Reads or sets the user writing the file. Useful to know which user opened the file in Excel when you want to save and the file is in use.

Events

Name Description
OnPassword It is called when opening a password protected file, so you can supply the correct password.
If you know beforehand that the file is protected you do not need this event, just use the OpenPassword method on this object.