ODS dosyalarını C++ ile Şifrele ve Çöz

OpenOffice Calc ile Şifrele

  1. Save as seçeneğini belirleyin ve Save With Password kutusuna tıklayın.
  2. Kaydet düğmesini tıklayın.
  3. Açılan Set Parola penceresinde, hem Açmak için Parolayı Girin hem de Parolayı Onaylayın alanlarına istediğiniz parolayı yazın.
  4. Dosyayı kaydetmek için Tamam düğmesini tıklayın.

Aspose.Cells for C++ kullanarak ODS dosyasını şifrele

Bir ODS dosyasını şifrelemek için dosyayı yükleyin ve kaydetmeden önce WorkbookSettings.GetPassword() değerini gerçek parolaya ayarlayın. Oluşturulan şifrelenmiş ODS dosyası yalnızca OpenOffice’de açılabilir.

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

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

    // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C++

    // Source directory path
    U16String sourceDir = u"..\\Data\\01_SourceDirectory\\";

    // Output directory path
    U16String outputDir = u"..\\Data\\02_OutputDirectory\\";

    // Open an ODS file
    Workbook workbook(sourceDir + u"sampleODSFile.ods");

    // Password protect the file
    workbook.GetSettings().SetPassword(u"1234");

    // Save the ODS file
    workbook.Save(outputDir + u"outputEncryptedODSFile.ods");

    std::cout << "ODS file password protected and saved successfully!" << std::endl;

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

Aspose.Cells for C++ kullanarak ODS dosyasını şifresini çöz

Bir ODS dosyasını şifre çözmek için, LoadOptions.GetPassword() özelliğine şifre girerek dosyayı yükleyin. Dosya yüklendikten sonra, WorkbookSettings.GetPassword() dizesini null yapın.

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

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

    // Path to the source directory
    U16String sourceDir = u"..\\Data\\01_SourceDirectory\\";

    // Output directory
    U16String outputDir = u"..\\Data\\02_OutputDirectory\\";

    // Open an encrypted ODS file
    LoadOptions loadOptions(LoadFormat::Ods);

    // Set original password
    loadOptions.SetPassword(u"1234");

    // Load the encrypted ODS file with the appropriate load options
    Workbook workbook(sourceDir + u"sampleEncryptedODSFile.ods", loadOptions);

    // Set the password to null
    workbook.GetSettings().SetPassword(nullptr);

    // Save the decrypted ODS file
    workbook.Save(outputDir + u"outputDecryptedODSFile.ods");

    std::cout << "Decrypted ODS file saved successfully!" << std::endl;

    Aspose::Cells::Cleanup();
}