Skydda och avskydda arbetsboksstrukturen med C++

Skydda och avskydda arbetsboksstrukturen i MS Excel

skydda och avskydda arbetsbokens struktur

  1. Klicka på Granska > Skydda arbetsbok.
  2. Ange ett lösenord i Lösenordsrutan.
  3. Välj OK, ange lösenordet igen för att bekräfta det, och välj sedan OK igen.

Skydda arbetsboksens struktur med Aspose.Cells for C++

Bara behöver följande enkla koder för att implementera skydd av arbetsbokens struktur för Excel-filer.

#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();
}

Avskydda arbetsboksstrukturen med Aspose.Cells for C++

Det är enkelt att avskydda arbetsbokens struktur med Aspose.Cells API.

#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();
}