Rileva se il foglio di lavoro è protetto da password
Contents
[
Hide
]
È possibile proteggere separatamente le cartelle di lavoro e i fogli di lavoro. Ad esempio, un foglio di calcolo può contenere uno o più fogli di lavoro protetti da password, tuttavia il foglio di calcolo stesso può essere protetto o meno. Aspose.Cells Le API forniscono i mezzi per rilevare se un determinato foglio di lavoro è protetto da password o meno. Questo articolo illustra l’utilizzo di Aspose.Cells for .NET API per ottenere lo stesso risultato.
Aspose.Cells for .NET 8.7.0 ha esposto ilProtezione.IsProtectedWithPassword proprietà per rilevare se un foglio di lavoro è protetto da password o meno. Tipo booleanoProtezione.IsProtectedWithPassword resi di proprietàVERO SeFoglio di lavoro è protetto da password efalso altrimenti.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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"); | |
} |