Skydda Cells
Contents
[
Hide
]
Det här ämnet beskriver några tekniker för att skydda celler. Genom att använda dessa tekniker kan utvecklare begränsa användare från att redigera alla eller ett utvalt cellområde i ett kalkylblad.
Skyddar Cells
Aspose.Cells.GridWeb tillhandahåller några olika tekniker för att kontrollera skyddsnivån på celler när kontrollen är iRedigeringsläge (standardläget). Detta skyddar celler från att modifieras av slutanvändare.
Gör allt Cells Endast läsning
Om du vill ställa in alla celler i ett kalkylblad till skrivskyddade anropar du kalkylbladets SetAllCellsReadonly-metod.
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 | |
// 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(); |
Gör allt Cells redigerbart
Om du vill ta bort skyddet från alla celler, anropar du kalkylbladets SetAllCellsEditable-metod. Denna metod har motsatt effekt mot SetAllCellsReadonly-metoden.
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 | |
// 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(); |
Göra valda Cells Endast läsning
Så här skyddar du endast ett antal celler:
- Gör först alla celler redigerbara genom att anropa metoden SetAllCellsEditable.
- Ange intervallet av celler som ska skyddas genom att anropa kalkylbladets SetReadonlyRange-metod. Denna metod tar antalet rader och kolumner för att specificera cellintervallet.
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 | |
// 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); |
Gör valda Cells redigerbara
Så här tar du bort skyddet av en rad celler:
- Gör alla celler läsbara genom att anropa SetAllCellsReadonly-metoden.
- Ange intervallet av celler som ska redigeras genom att anropa kalkylbladets SetEditableRange-metod. Denna metod tar antalet rader och kolumner för att specificera cellintervallet.
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 | |
// 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); |