officefileapi-devexpress-dot-spreadsheet-dot-writeprotectionoptions-13967d0b.md
Returns or specifies the name of the user who write-protected the workbook.
Namespace : DevExpress.Spreadsheet
Assembly : DevExpress.Spreadsheet.v25.2.Core.dll
NuGet Package : DevExpress.Spreadsheet.Core
string UserName { get; set; }
Property UserName As String
| Type | Description |
|---|---|
| String |
The user’s name.
|
You can access this nested property as listed below:
| Object Type | Path to UserName |
|---|---|
| DocumentSettings |
.WriteProtection .UserName
|
The following example demonstrates how to write-protect a workbook:
using(var workbook = new Workbook()) {
var wpOptions = workbook.DocumentSettings.WriteProtection;
wpOptions.SetPassword("Password");
wpOptions.UserName = "John Smith";
workbook.SaveDocument("WriteProtectedDocument.xlsx");
}
Using workbook As New Workbook()
Dim wpOptions As WriteProtectionOptions = workbook.DocumentSettings.WriteProtection
wpOptions.SetPassword("Password")
wpOptions.UserName = "John Smith"
workbook.SaveDocument("WriteProtectedDocument.xlsx")
End Using
When users open this workbook in Microsoft® Excel®, it prompts them to enter a password to modify the document.
See Also
WriteProtectionOptions Interface