Cifrare e decifrare file ODS con Node.js tramite C++

Crittografa con OpenOffice Calc

  1. Seleziona Salva come e clicca sulla casella Salva con password.
  2. Fai clic sul pulsante Salva.
  3. Digita la password desiderata nei campi Inserisci password per aprire e Conferma password nella finestra Imposta password che si apre.
  4. Fare clic sul pulsante OK per salvare il file.

Cifra il file ODS con Aspose.Cells for Node.js via C++

Per crittografare un file ODS, caricare il file e impostare il valore WorkbookSettings.getPassword() sulla password effettiva prima di salvarlo. Il file ODS crittografato in output può essere aperto solo in OpenOffice.

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

// The path to the documents directory.
const sourceDir = path.join(__dirname, "source");
const outputDir = path.join(__dirname, "output");

// Open an ODS file
const workbook = new AsposeCells.Workbook(path.join(sourceDir, "sampleODSFile.ods"));

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

// Save the ODS file
workbook.save(path.join(outputDir, "outputEncryptedODSFile.ods"));

Decrittografare file ODS con Aspose.Cells for Node.js via C++

Per decriptare un file ODS, caricare il file fornendo una password in LoadOptions.getPassword(). Una volta caricato, impostare la stringa WorkbookSettings.getPassword() su null.

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

// The path to the documents directory.
const sourceDir = path.join(__dirname, "data");
// Output directory
const outputDir = path.join(__dirname, "output");

// Open an encrypted ODS file
const loadOptions = new AsposeCells.LoadOptions(AsposeCells.LoadFormat.Ods);

// Set original password
loadOptions.setPassword("1234");

// Load the encrypted ODS file with the appropriate load options
const workbook = new AsposeCells.Workbook(path.join(sourceDir, "sampleEncryptedODSFile.ods"), loadOptions);

// Set the password to null
workbook.getSettings().setPassword(null);

// Save the decrypted ODS file
workbook.save(outputDir + "outputDecryptedODSFile.ods");