Koruyun Cells

Koruma Cells

Aspose.Cells.GridWeb, kontrol devredeyken hücrelerdeki koruma seviyesini kontrol etmek için birkaç farklı teknik sunar.Düzenleme modu (varsayılan mod). Bu, hücreleri son kullanıcılar tarafından değiştirilmekten korur.

Tümünü Yapma Cells Salt Okunur

Çalışma sayfasındaki tüm hücreleri salt okunur olarak ayarlamak için çalışma sayfasının SetAllCellsReadonly yöntemini çağırın.

// 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’in Tümünü Düzenlenebilir Hale Getirmek

Tüm hücrelerden korumayı kaldırmak için çalışma sayfasının SetAllCellsEditable yöntemini çağırın. Bu yöntem, SetAllCellsReadonly yönteminin tersi etkiye sahiptir.

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

Seçileni Yapma Cells Salt Okunur

Yalnızca bir hücre aralığını korumak için:

  1. Önce SetAllCellsEditable yöntemini çağırarak tüm hücreleri düzenlenebilir yapın.
  2. Çalışma sayfasının SetReadonlyRange yöntemini çağırarak korunacak hücre aralığını belirtin. Bu yöntem, hücre aralığını belirtmek için satır ve sütun sayısını alır.
// 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);

Seçilen Cells Düzenlenebilir Hale Getiriliyor

Bir hücre aralığının korumasını kaldırmak için:

  1. SetAllCellsReadonly yöntemini çağırarak tüm hücreleri salt okunur yapın.
  2. Çalışma sayfasının SetEditableRange yöntemini çağırarak düzenlenebilir olacak hücre aralığını belirtin. Bu yöntem, hücre aralığını belirtmek için satır ve sütun sayısını alır.
// 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);