حماية وإلغاء حماية ورقة العمل باستخدام Node.js عبر C++

حماية وإلغاء حماية ورقة العمل في MS Excel

حماية وإلغاء حماية ورقة العمل

١. انقر فوق مراجعة > حماية ورقة عمل.
١. أدخل كلمة مرور في مربع الكلمة السرية.
١. حدد خيارات السماح.
١. حدد موافق, أدخل كلمة المرور مرة أخرى لتأكيدها، ثم حدد موافق مجددًا.

حماية ورقة العمل باستخدام Aspose.Cells for Node.js via C++

متطلبات الترميز البسيطة التالية فقط لتنفيذ حماية هيكل دفتر العمل لملفات Excel.

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

// The path to the documents directory.
const dataDir = path.join(__dirname, "data");
// Create a new file.
const workbook = new AsposeCells.Workbook();
// Gets the first worksheet.
const sheet = workbook.getWorksheets().get(0);
// Protect contents of the worksheet.
sheet.protect(AsposeCells.ProtectionType.Contents);
// Protect worksheet with password.
sheet.getProtection().setPassword("test");
// Save as Excel file.
workbook.save("Book1.xlsx");

إلغاء حماية ورقة العمل باستخدام 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");
// Create a new file.
const workbook = new AsposeCells.Workbook(filePath);
// Gets the first worksheet.
const sheet = workbook.getWorksheets().get(0);
// Protect contents of the worksheet.
sheet.unprotect("password");
// Save Excel file.
workbook.save("Book1.xlsx");

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