الكشف عما إذا كانت ورقة العمل محمية بكلمة مرور
Contents
[
Hide
]
من الممكن حماية الدفاتر المحاسبية وأوراق العمل بشكل منفصل. على سبيل المثال ، قد تحتوي جدول بيانات على ورقة واحدة أو أكثر محمية بكلمة مرور ، ومع ذلك ، قد تكون جدول البيانات نفسه محميًا أو قد لا يكون محميًا. توفر واجهات برمجة التطبيقات في Aspose.Cells الوسيلة للكشف عما إذا كانت ورقة العمل المحددة محمية بكلمة مرور أم لا. يوضح هذا المقال استخدام واجهة برمجة التطبيقات Aspose.Cells for .NET لتحقيق الهدف نفسه.
قد قامت Aspose.Cells for .NET 8.7.0 بتعريض الخاصية Protection.IsProtectedWithPassword للكشف عما إذا كانت ورقة العمل محمية بكلمة مرور أم لا. تعيد الخاصية Protection.IsProtectedWithPassword من نوع بولياني true إذا كانت Worksheet محمية بكلمة مرور و false إذا لم تكن.
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"); | |
} |