Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active October 15, 2021 03:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-com-gists/51e7785a67fa69c534d76021f2b70a1a to your computer and use it in GitHub Desktop.
Save aspose-com-gists/51e7785a67fa69c534d76021f2b70a1a to your computer and use it in GitHub Desktop.
Encrypt Decrypt Excel Files in Node.js
// Initialize loading options
var loadOptions = new aspose.cells.LoadOptions(LoadFormat.XLSX);
// Set original password
loadOptions.setPassword("1234");
// Instantiate a Workbook object with Excel file's path
var workbook = new aspose.cells.Workbook("encrypted-workbook.xlsx", loadOptions);
// Set password to null
workbook.getSettings().setPassword(null);
// Save the file
workbook.save("decrypted.xlsx");
// Open the Excel file
var workbook = new aspose.cells.Workbook("Excel.xlsx");
// Password protect the file
workbook.getSettings().setPassword("1234");
// Specify Strong Encryption type (RC4, Microsoft Strong Cryptographic Provider)
workbook.setEncryptionOptions(aspose.cells.EncryptionType.STRONG_CRYPTOGRAPHIC_PROVIDER, 128);
// Save the file
workbook.save("encrypted.xlsx");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment