Protege y desbloquea la estructura del libro con C++

Proteger y desbloquear la estructura del libro en MS Excel

proteger y desproteger la estructura del libro

  1. Haga clic en Revisar > Proteger libro.
  2. Ingrese una contraseña en el cuadro de Contraseña.
  3. Seleccione Aceptar, vuelva a ingresar la contraseña para confirmarla y luego seleccione Aceptar nuevamente.

Proteger estructura del libro usando Aspose.Cells for C++

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.

#include <iostream>
#include "Aspose.Cells.h"
using namespace Aspose::Cells;

int main()
{
    Aspose::Cells::Startup();

    // Create a new workbook
    Workbook workbook;

    // Protect workbook structure with a password
    workbook.Protect(ProtectionType::Structure, u"password");

    // Save the workbook to a file
    workbook.Save(u"Book1.xlsx");

    std::cout << "Workbook created and protected successfully!" << std::endl;

    Aspose::Cells::Cleanup();
}

Desproteger estructura del libro usando Aspose.Cells for C++

Desproteger la estructura del libro es fácil con la API de Aspose.Cells.

#include <iostream>
#include "Aspose.Cells.h"

using namespace Aspose::Cells;

int main()
{
    Aspose::Cells::Startup();

    // Open an Excel file which workbook structure is protected.
    U16String inputFilePath = u"Book1.xlsx";
    Workbook workbook(inputFilePath);

    // Unprotect workbook structure.
    workbook.Unprotect(u"password");

    // Save Excel file.
    workbook.Save(inputFilePath);

    std::cout << "Workbook structure unprotected and saved successfully!" << std::endl;

    Aspose::Cells::Cleanup();
}