Erkennen, ob ein Arbeitsblatt passwortgeschützt ist mit C++

Contents
[ ]

Aspose.Cells for C++ hat die Eigenschaft Protection.IsProtectedWithPassword freigegeben, um zu erkennen, ob ein Arbeitsblatt passwortgeschützt ist oder nicht. Die boolesche Eigenschaft Protection.IsProtectedWithPassword gibt true zurück, wenn Worksheet passwortgeschützt ist, und false, wenn nicht.

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

using namespace Aspose::Cells;

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

    // Source directory path
    U16String srcDir(u"..\\Data\\01_SourceDirectory\\");

    // Create an instance of Workbook and load a spreadsheet
    Workbook book(srcDir + u"sample.xlsx");

    // Access the protected Worksheet
    Worksheet sheet = book.GetWorksheets().Get(0);

    // Check if Worksheet is password protected
    if (sheet.GetProtection().IsProtectedWithPassword())
    {
        std::cout << "Worksheet is password protected" << std::endl;
    }
    else
    {
        std::cout << "Worksheet is not password protected" << std::endl;
    }

    Aspose::Cells::Cleanup();
    return 0;
}