Protection.IsProtectedWithPassword
Protection.IsProtectedWithPassword property
Indicates whether the worksheets is protected with password.
public bool IsProtectedWithPassword { get; }
Examples
using System;
using Aspose.Cells;
namespace AsposeCellsExamples
{
public class ProtectionPropertyIsProtectedWithPasswordDemo
{
public static void Run()
{
// Create a new workbook
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
// Access worksheet protection settings
Protection protection = worksheet.Protection;
// Set protection password
protection.Password = "test123";
// Check if worksheet is password protected
bool isProtectedWithPassword = protection.IsProtectedWithPassword;
Console.WriteLine("Is worksheet protected with password: " + isProtectedWithPassword);
// Save the workbook
workbook.Save("PasswordProtectionDemo.xlsx");
}
}
}
See Also
- class Protection
- namespace Aspose.Cells
- assembly Aspose.Cells