Proteggi e Rimuovi la protezione dal Foglio di Lavoro con Node.js tramite C++

Proteggere e proteggere il foglio di lavoro in MS Excel

proteggere e proteggere il foglio di lavoro

  1. Fare clic su Revisione > Proteggi foglio di lavoro.
  2. Inserire una password nella casella di Password.
  3. Selezionare le opzioni consenti.
  4. Selezionare OK, reinserire la password per confermarla e quindi selezionare di nuovo OK.

** Proteggi il Foglio di Lavoro usando Aspose.Cells for Node.js via C++**

È sufficiente utilizzare le seguenti linee di codice per implementare la protezione della struttura della cartella di lavoro dei file di 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");

Rimuovi la protezione dal Foglio di Lavoro usando Aspose.Cells for Node.js via C++

Rimuovere la protezione dal foglio di lavoro è facile con l’API Aspose.Cells. Se il foglio di lavoro è protetto da password, è richiesta la password corretta.

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");

Argomenti avanzati