Protéger et Déprotéger la Structure du Classeur avec Node.js via C++

Protéger et déprotéger la structure du classeur dans MS Excel

Protéger et déprotéger la structure du classeur

  1. Cliquez sur Relecture > Protéger le classeur.
  2. Entrez un mot de passe dans la boîte de mot de passe.
  3. Sélectionnez OK, saisissez à nouveau le mot de passe pour le confirmer, puis sélectionnez à nouveau OK.

Protéger la structure du classeur en utilisant Aspose.Cells for Node.js via C++

Il suffit d’utiliser les lignes de code suivantes pour implémenter la protection de la structure du classeur Excel.

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();
// Protect workbook structure.
workbook.protect(AsposeCells.ProtectionType.Structure, "password");
// Save Excel file.
workbook.save(filePath);

Déprotéger la structure du classeur en utilisant Aspose.Cells for Node.js via C++

La déprotection de la structure du classeur est facile avec l’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 an Excel file which workbook structure is protected.
const workbook = new AsposeCells.Workbook(filePath);
// Unprotect workbook structure.
workbook.unprotect("password");
// Save Excel file.
workbook.save(filePath);