Proteggi e Sblocca il Foglio di Lavoro con C++

Proteggi e Sblocca il Foglio di Lavoro in MS Excel

proteggere e proteggere il foglio di lavoro

  1. Fare clic su Revisione > Proteggi foglio di lavoro.
  2. Inserire una password nella casella di Password.
  3. Selezionare le opzioni consenti.
  4. Selezionare OK, reinserire la password per confermarla e quindi selezionare di nuovo OK.

Proteggi il Foglio di Lavoro usando Aspose.Cells for C++

È sufficiente utilizzare le seguenti linee di codice per implementare la protezione della struttura della cartella di lavoro dei file di Excel.

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

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

    // Create a new workbook
    Workbook workbook;

    // Get the first worksheet
    Worksheet sheet = workbook.GetWorksheets().Get(0);

    // Protect contents of the worksheet
    sheet.Protect(ProtectionType::Contents);

    // Protect worksheet with password
    sheet.GetProtection().SetPassword(u"test");

    // Save as Excel file
    workbook.Save(u"Book1.xlsx");

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

    Aspose::Cells::Cleanup();
}

Sblocca il Foglio di Lavoro usando Aspose.Cells for C++

Sbloccare un foglio di lavoro è facile con l’API Aspose.Cells. Se il foglio di lavoro è protetto da password, è necessaria una password corretta.

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

using namespace Aspose::Cells;

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

    // Create a new workbook
    Workbook workbook(u"Book1.xlsx");

    // Get the first worksheet
    Worksheet sheet = workbook.GetWorksheets().Get(0);

    // Unprotect the worksheet with password
    sheet.Unprotect(u"password");

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

    std::cout << "Worksheet unprotected successfully!" << std::endl;

    Aspose::Cells::Cleanup();
}

Argomenti avanzati