حماية Cells

حماية Cells

Aspose.Cells.GridWeb يوفر بعض التقنيات المختلفة للتحكم في مستوى الحماية على الخلايا عندما يكون عنصر التحكم فيوضع التحرير (الوضع الافتراضي). هذا يحمي الخلايا من التعديل من قبل المستخدمين النهائيين.

جعل الكل Cells للقراءة فقط

لتعيين جميع الخلايا في ورقة العمل للقراءة فقط ، قم باستدعاء أسلوب SetAllCellsReadonly الخاص بورقة العمل.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Accessing the reference of the worksheet that is currently active
GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex];
// Setting all cells of the worksheet to Readonly
sheet.SetAllCellsReadonly();

جعل كل Cells قابل للتحرير

لإزالة الحماية من جميع الخلايا ، قم باستدعاء أسلوب SetAllCellsEditable الخاص بورقة العمل. هذه الطريقة لها تأثير معاكس لأسلوب SetAllCellsReadonly.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Accessing the reference of the worksheet that is currently active
GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex];
// Setting all cells of the worksheet to Editable
sheet.SetAllCellsEditable();

جعل Cells المحدد للقراءة فقط

لحماية نطاق من الخلايا فقط:

  1. أولاً ، اجعل جميع الخلايا قابلة للتحرير عن طريق استدعاء طريقة SetAllCellsEditable.
  2. حدد نطاق الخلايا المطلوب حمايتها عن طريق استدعاء أسلوب SetReadonlyRange الخاص بورقة العمل. تأخذ هذه الطريقة عدد الصفوف والأعمدة لتحديد نطاق الخلايا.
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Accessing the reference of the worksheet that is currently active
GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex];
// Setting all cells of the worksheet to Editable first
sheet.SetAllCellsEditable();
// Finally, Setting selected cells of the worksheet to Readonly
sheet.SetReadonlyRange(3, 2, 4, 1);

جعل مختارة Cells قابلة للتحرير

لإلغاء حماية نطاق من الخلايا:

  1. اجعل كل الخلايا مقروءة فقط عن طريق استدعاء الأسلوب SetAllCellsReadonly.
  2. حدد نطاق الخلايا التي يمكن تحريرها عن طريق استدعاء أسلوب SetEditableRange الخاص بورقة العمل. تأخذ هذه الطريقة عدد الصفوف والأعمدة لتحديد نطاق الخلايا.
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Accessing the reference of the worksheet that is currently active
GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex];
// Setting all cells of the worksheet to Readonly first
sheet.SetAllCellsReadonly();
// Finally, Setting selected cells of the worksheet to Editable
sheet.SetEditableRange(3, 2, 4, 1);