C++ ile Çalışma Sayfasını Koruma Parolasını Doğrula
Contents
[
Hide
]
Aspose.Cells API’leri, Protection sınıfını geliştirerek bazı kullanışlı özellikler ve yöntemler eklemiştir. Bu tür bir yöntem, bir string örneği olarak bir şifreyi belirtmeyi ve aynı şifrenin Worksheet korumak için kullanılıp kullanılmadığını doğrulamayı mümkün kılar.
Protection.VerifyPassword yöntemi, belirtilen parolanın, koruma altına alınan çalışma sayfasına uygulanan parola ile eşleşip eşleşmediğini doğru veya yanlış döner. Aşağıdaki kod parçası, parolayı tespit etmek ve doğrulamak için Protection.VerifyPassword ve Protection.IsProtectedWithPassword özellikleri ile birlikte kullanır.
#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())
{
// Verify the password used to protect the Worksheet
if (sheet.GetProtection().VerifyPassword(u"1234"))
{
std::cout << "Specified password has matched" << std::endl;
}
else
{
std::cout << "Specified password has not matched" << std::endl;
}
}
Aspose::Cells::Cleanup();
return 0;
}