Proteger y Desproteger Hoja de Cálculo
Contents
[
Hide
]
Para evitar que otros usuarios cambien, muevan o eliminen datos en una hoja de cálculo de forma accidental o deliberada, puede bloquear las celdas en su hoja de cálculo de Excel y luego proteger la hoja con una contraseña.
Proteger y desproteger Hoja de Cálculo en MS Excel
- Haga clic en Revisar > Proteger Hoja.
- Ingrese una contraseña en el cuadro de Contraseña.
- Seleccione las opciones de permitir.
- Seleccione Aceptar, vuelva a ingresar la contraseña para confirmarla y luego seleccione Aceptar nuevamente.
Proteger Hoja de Cálculo Usando Aspose.Cell for .Net
Solo necesitas las siguientes líneas de código simples para implementar la protección de la estructura del libro de trabajo de archivos de Excel.
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
//Create a new file. | |
Workbook workbook = new Workbook(); | |
//Gets the first worksheet. | |
Worksheet sheet = workbook.Worksheets[0]; | |
//Protect contents of the worksheet. | |
sheet.Protect(ProtectionType.Contents); | |
//Protect worksheet with password. | |
sheet.Protection.Password = "test"; | |
//Save as Excel file. | |
workbook.Save("Book1.xlsx"); |
Desproteger Hoja de Cálculo Usando Aspose.Cell for .Net
Desproteger la hoja de cálculo es fácil con la API de Aspose.Cells. Si la hoja de cálculo está protegida con contraseña, se requiere una contraseña correcta.
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
//Create a new file. | |
Workbook workbook = new Workbook("Book1.xlsx"); | |
//Gets the first worksheet. | |
Worksheet sheet = workbook.Worksheets[0]; | |
//Protect contents of the worksheet. | |
sheet.Unprotect("password"); | |
//Save Excel file. | |
workbook.Save("Book1.xlsx"); |