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.v24.2.Core.dll
NuGet Package: DevExpress.Spreadsheet.Core
Declaration
Property Value
Type | Description |
---|---|
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 Type | Path to ReadOnlyRecommended |
---|---|
DocumentSettings |
|
Remarks
The following example demonstrates how to make a workbook read-only:
using(var workbook = new Workbook())
{
var wpOptions = workbook.DocumentSettings.WriteProtection;
wpOptions.ReadOnlyRecommended = true;
workbook.SaveDocument("WriteProtectedDocument.xlsx");
}
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.