Proteger Cells
Contents
[
Hide
]
En este tema se describen algunas técnicas para proteger las células. El uso de estas técnicas permite a los desarrolladores restringir que los usuarios editen todas las celdas o un rango seleccionado de una hoja de trabajo.
Protegiendo Cells
Aspose.Cells.GridWeb proporciona algunas técnicas diferentes para controlar el nivel de protección en las celdas cuando el control está enModo de edición (el modo predeterminado). Esto protege las celdas de ser modificadas por los usuarios finales.
Hacer que todo Cells sea de solo lectura
Para configurar todas las celdas de una hoja de cálculo para que sean de solo lectura, llame al método SetAllCellsReadonly de la hoja de cálculo.
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(); |
Haciendo todo Cells Editable
Para eliminar la protección de todas las celdas, llame al método SetAllCellsEditable de la hoja de trabajo. Este método tiene el efecto opuesto al método SetAllCellsReadonly.
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(); |
Hacer seleccionado Cells Solo lectura
Para proteger solo un rango de celdas:
- Primero haga que todas las celdas sean editables llamando al método SetAllCellsEditable.
- Especifique el rango de celdas que desea proteger llamando al método SetReadonlyRange de la hoja de cálculo. Este método toma el número de filas y columnas para especificar el rango de celdas.
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); |
Haciendo Editable Cells Seleccionado
Para desproteger un rango de celdas:
- Haga que todas las celdas sean de solo lectura llamando al método SetAllCellsReadonly.
- Especifique el rango de celdas que se pueden editar llamando al método SetEditableRange de la hoja de cálculo. Este método toma el número de filas y columnas para especificar el rango de celdas.
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); |