تشفير وفك تشفير ملفات إكسل مع Node.js عبر C++

استخدام Microsoft Excel

لضبط إعدادات تشفير الملف في Microsoft Excel (هنا Microsoft Excel 2003):

  1. من قائمة الأدوات، حدد الخيارات. ستظهر نافذة حوارية.
  2. اختر علامة التبويب الأمان.
  3. أدخل كلمة مرور وانقر على مُتقدم
  4. اختر نوع التشفير و confirms كلمة المرور.

تشفير ملف إكسل باستخدام Aspose.Cells for Node.js via C++

يوضح المثال التالي كيفية تشفير وحماية كلمة المرور لملف إكسل باستخدام API الخاص بـ Aspose.Cells.

const path = require("path");
const AsposeCells = require("aspose.cells.node");

// The path to the documents directory.
const dataDir = path.join(__dirname, "data");
const filePath = path.join(dataDir, "Book1.xls");

// Instantiate a Workbook object.
// Open an excel file.
const workbook = new AsposeCells.Workbook(filePath);

// Specify XOR encryption type.
workbook.setEncryptionOptions(AsposeCells.EncryptionType.XOR, 40);

// Specify Strong Encryption type (RC4, Microsoft Strong Cryptographic Provider).
workbook.setEncryptionOptions(AsposeCells.EncryptionType.StrongCryptographicProvider, 128);

// Password protect the file.
workbook.getSettings().setPassword("1234");

// Save the excel file.
workbook.save(path.join(dataDir, "encryptedBook1.out.xls"));

تحديد خيار كلمة المرور للتعديل

المثال التالي يوضح كيفية ضبط خيار Microsoft Excel كلمة المرور للتعديل لملف موجود باستخدام واجهة برمجة التطبيقات Aspose.Cells.

const path = require("path");
const AsposeCells = require("aspose.cells.node");

// The path to the documents directory.
const dataDir = path.join(__dirname, "data");

// Instantiate a Workbook object.
// Open an excel file.
const workbook = new AsposeCells.Workbook(path.join(dataDir, "Book1.xls"));

// Set the password for modification.
workbook.getSettings().getWriteProtection().setPassword("1234");

// Save the excel file.
workbook.save(path.join(dataDir, "SpecifyPasswordToModifyOption.out.xls"));

فك تشفير ملف إكسل باستخدام Aspose.Cells for Node.js via C++

من السهل جدًا فتح ملف إكسل محمي بكلمة مرور وفكه باستخدام API الخاص بـ Aspose.Cells كما هو موضح في الكود التالي:

const path = require("path");
const AsposeCells = require("aspose.cells.node");

// The path to the documents directory.
const dataDir = path.join(__dirname, "data");
const filePath = path.join(dataDir, "Book1.xlsx");

// Open encrypted file with password.
const loadOptions = new AsposeCells.LoadOptions();
loadOptions.setPassword("password");
const workbook = new AsposeCells.Workbook(filePath, loadOptions);

// Remove password.
workbook.getSettings().setPassword(null);

// Save the file.
workbook.save(filePath);

مواضيع متقدمة