حماية الخلايا

حماية الخلايا

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

جعل جميع الخلايا للقراءة فقط

لتعيين جميع الخلايا في ورقة عمل للقراءة فقط، اتصل بطريقة 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();

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

لإزالة الحماية من جميع الخلايا، اتصل بطريقة 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();

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

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

  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);

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

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

  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);