Back to Devexpress

WriteProtectionOptions.ReadOnlyRecommended Property

officefileapi-devexpress-dot-spreadsheet-dot-writeprotectionoptions.md

latest2.8 KB
Original Source

WriteProtectionOptions.ReadOnlyRecommended Property

Returns or specifies whether the author of the workbook recommended that it be opened as read-only.

Namespace : DevExpress.Spreadsheet

Assembly : DevExpress.Spreadsheet.v25.2.Core.dll

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

csharp
bool ReadOnlyRecommended { get; set; }
vb
Property ReadOnlyRecommended As Boolean

Property Value

TypeDescription
Boolean

true if the author recommended the document to be opened as read-only; otherwise, false.

|

Property Paths

You can access this nested property as listed below:

Object TypePath to ReadOnlyRecommended
DocumentSettings

.WriteProtection .ReadOnlyRecommended

|

Remarks

The following example demonstrates how to make a workbook read-only:

csharp
using(var workbook = new Workbook()) {
    var wpOptions = workbook.DocumentSettings.WriteProtection;
    wpOptions.ReadOnlyRecommended = true;
    workbook.SaveDocument("WriteProtectedDocument.xlsx");
}
vb
Using workbook As New Workbook()
    Dim wpOptions As WriteProtectionOptions = workbook.DocumentSettings.WriteProtection
  wpOptions.ReadOnlyRecommended = True
    workbook.SaveDocument("WriteProtectedDocument.xlsx")
End Using

When users open this workbook in Microsoft® Excel®, it prompts them to open the document as read-only.

The WriteProtectionOptions.SetPassword method allows you to specify a password to prevent modifications from unauthorized users.

Note

Write-protection options are ignored when you open a document in the WinForms or WPF Spreadsheet control. Handle the SpreadsheetControl.DocumentLoaded event to check the document’s ReadOnlyRecommended value and to make the control read-only when needed.

See Also

WriteProtectionOptions Interface

WriteProtectionOptions Members

DevExpress.Spreadsheet Namespace