officefileapi-devexpress-dot-spreadsheet-dot-writeprotectionoptions.md
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
bool ReadOnlyRecommended { get; set; }
Property ReadOnlyRecommended As Boolean
| Type | Description |
|---|---|
| Boolean |
true if the author recommended the document to be opened as read-only; otherwise, false.
|
You can access this nested property as listed below:
| Object Type | Path to ReadOnlyRecommended |
|---|---|
| DocumentSettings |
.WriteProtection .ReadOnlyRecommended
|
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");
}
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