إعدادات الحماية المتقدمة منذ Excel XP

مقدمة

تعمل إعدادات الحماية هذه على تقييد المستخدمين أو السماح لهم بما يلي:

  • احذف الصفوف أو الأعمدة.
  • تحرير المحتويات أو الكائنات أو السيناريوهات.
  • تنسيق الخلايا أو الصفوف أو الأعمدة.
  • قم بإدراج صفوف أو أعمدة أو ارتباطات تشعبية.
  • حدد الخلايا المؤمنة أو غير المؤمنة.
  • استخدم الجداول المحورية وغير ذلك الكثير.

يدعم Aspose.Cells كافة إعدادات الحماية المتقدمة التي يوفرها Excel XP أو الإصدارات الأحدث.

إعدادات الحماية المتقدمة باستخدام Excel XP والإصدارات الأحدث

لعرض إعدادات الحماية المتوفرة في Excel XP:

  1. منأدوات القائمة ، حددحماية تليهاورقة حماية. سيتم عرض مربع حوار.

لعرض إعدادات الحماية المتوفرة في Excel 2016

  1. منملف القائمة ، حددحماية المصنف تليهاحماية الورقة الحالية.
  2. حدد ملفورقة حماية في الإعادة النظر قائمة.

باتباع الخطوات المذكورة أعلاه ، سيظهر مربع حوار حيث يمكنك السماح بميزات أوراق العمل أو تقييدها أو تطبيق كلمة مرور على ورقة العمل.

إعدادات الحماية المتقدمة باستخدام Aspose.Cells

Aspose.Cells يدعم كل إعدادات الحماية المتقدمة.

Aspose.Cells يوفر فصل دراسي ،دفتر العمل ، يمثل ملف Excel Microsoft. الدفتر العمل فئة تحتوي علىأوراق عمل مجموعة تسمح بالوصول إلى كل ورقة عمل في ملف Excel. يتم تمثيل ورقة العمل بواسطةورقة عملصف دراسي.

الورقة عمل فئة توفرحماية الخاصية المستخدمة لتطبيق إعدادات الحماية المتقدمة هذه. الحماية الخاصية هي في الواقع كائن منحمايةفئة تضم العديد من الخصائص المنطقية لتعطيل القيود أو تمكينها.

يوجد أدناه مثال صغير للتطبيق. يفتح ملف Excel ويستخدم معظم إعدادات الحماية المتقدمة التي يدعمها Excel XP والإصدارات الأحدث.

// 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);
// Creating a file stream containing the Excel file to be opened
FileStream fstream = new FileStream(dataDir + "book1.xls", FileMode.Open);
// Instantiating a Workbook object
// Opening the Excel file through the file stream
Workbook excel = new Workbook(fstream);
// Accessing the first worksheet in the Excel file
Worksheet worksheet = excel.Worksheets[0];
// Restricting users to delete columns of the worksheet
worksheet.Protection.AllowDeletingColumn = false;
// Restricting users to delete row of the worksheet
worksheet.Protection.AllowDeletingRow = false;
// Restricting users to edit contents of the worksheet
worksheet.Protection.AllowEditingContent = false;
// Restricting users to edit objects of the worksheet
worksheet.Protection.AllowEditingObject = false;
// Restricting users to edit scenarios of the worksheet
worksheet.Protection.AllowEditingScenario = false;
// Restricting users to filter
worksheet.Protection.AllowFiltering = false;
// Allowing users to format cells of the worksheet
worksheet.Protection.AllowFormattingCell = true;
// Allowing users to format rows of the worksheet
worksheet.Protection.AllowFormattingRow = true;
// Allowing users to insert columns in the worksheet
worksheet.Protection.AllowFormattingColumn = true;
// Allowing users to insert hyperlinks in the worksheet
worksheet.Protection.AllowInsertingHyperlink = true;
// Allowing users to insert rows in the worksheet
worksheet.Protection.AllowInsertingRow = true;
// Allowing users to select locked cells of the worksheet
worksheet.Protection.AllowSelectingLockedCell = true;
// Allowing users to select unlocked cells of the worksheet
worksheet.Protection.AllowSelectingUnlockedCell = true;
// Allowing users to sort
worksheet.Protection.AllowSorting = true;
// Allowing users to use pivot tables in the worksheet
worksheet.Protection.AllowUsingPivotTable = true;
// Saving the modified Excel file
excel.Save(dataDir + "output.xls", SaveFormat.Excel97To2003);
// Closing the file stream to free all resources
fstream.Close();

Cell مشكلة الإقفال

إذا كنت تريد تقييد المستخدمين من تحرير الخلايا ، فيجب تأمين الخلايا قبل تطبيق أي إعدادات حماية. خلاف ذلك ، يمكن تحرير الخلايا حتى إذا كانت ورقة العمل محمية. في Microsoft Excel XP ، يمكن تأمين الخلايا من خلال مربع الحوار التالي:

مربع حوار لتأمين الخلايا في Excel XP
ما يجب القيام به: image_بديل_نص

من الممكن قفل الخلايا باستخدام Aspose.Cells API أيضًا. يمكن أن تحصل كل خليةأسلوب التنسيق الذي يحتوي على خاصية منطقية ،مقفل . تعيينمقفل ملكية لحقيقي أوخاطئة لقفل أو إلغاء قفل الخلية.

// 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);
Workbook workbook = new Workbook(dataDir + "Book1.xlsx");
// Accessing the first worksheet in the Excel file
Worksheet worksheet = workbook.Worksheets[0];
worksheet.Cells["A1"].GetStyle().IsLocked = true;
// Finally, Protect the sheet now.
worksheet.Protect(ProtectionType.All);
workbook.Save(dataDir + "output.xlsx");