تشفير وفك تشفير ملفات ODS باستخدام C++

التشفير باستخدام OpenOffice Calc

  1. اختر حفظ باسم وانقر على مربع الحفظ بكلمة مرور.
  2. انقر على زر حفظ.
  3. اكتب كلمة المرور المطلوبة في حقلي أدخل كلمة المرور للفتح و تأكيد كلمة المرور في نافذة تعيين كلمة المرور التي تفتح.
  4. انقر على زر موافق لحفظ الملف.

تشفير ملف ODS باستخدام Aspose.Cells for C++

لتشفير ملف ODS، قم بتحميل الملف وتعيين القيمة WorkbookSettings.GetPassword() إلى كلمة المرور الفعلية قبل حفظه. يمكن فتح ملف ODS المشفر الناتج في OpenOffice فقط.

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

فك تشفير ملف ODS باستخدام Aspose.Cells for C++

لفك تشفير ملف ODS، حمّل الملف عن طريق إدخال كلمة مرور في خاصية LoadOptions.GetPassword(). بمجرد تحميل الملف، اجعل السلسلة WorkbookSettings.GetPassword() فارغة.

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