Upptäck om arbetsbladet är lösenordsskyddat

Contents
[ ]

Aspose.Cells for .NET 8.7.0 har exponerat egenskapen Protection.IsProtectedWithPassword för att upptäcka om ett kalkylblad är lösenordsskyddat eller inte. Boolesk typ Protection.IsProtectedWithPassword returnerar true om Worksheet är lösenordsskyddat och false om inte.

// 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");
}