Détecter si la feuille de calcul est protégée par mot de passe

Contents
[ ]

Aspose.Cells for .NET 8.7.0 a exposé la propriété Protection.IsProtectedWithPassword pour détecter si une feuille de calcul est protégée par mot de passe ou non. La propriété de type booléen Protection.IsProtectedWithPassword renvoie true si la Worksheet est protégée par mot de passe et false si ce n’est pas le cas.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Create an instance of Workbook and load a spreadsheet
var book = new Workbook(dataDir + "sample.xlsx");
// Access the protected Worksheet
var sheet = book.Worksheets[0];
// Check if Worksheet is password protected
if (sheet.Protection.IsProtectedWithPassword)
{
Console.WriteLine("Worksheet is password protected");
}
else
{
Console.WriteLine("Worksheet is not password protected");
}