This article entails how to password protect an Excel file using Node.js. It has detailed information about setting up the development environment, a list of steps depicting the complete process, and a runnable sample code to encrypt Excel file using Node.js. You will also learn about setting different options for the encryption to be applied to the Excel file.
Steps to Password Protect Excel using Node.js
- Set the development environment for using Aspose.Cells for Node.js via Java to encrypt Excel file
- Create or load an existing Excel file using the workbook for setting the password
- Set the encryption options for the workbook
- Set the password using the settings of the workbook
- Save the resultant workbook after protecting it with a password
These steps provide the details on how to add password to Excel using Node.js. The process is initiated by loading the Workbook and setting its encryption options by providing the encryption type and key length. In the next steps, a password is set and the resultant Excel file is saved on the disk.
Code to Set Password for Excel using Node.js
The aforementioned sample code demonstrates how to put password on Excel file using Node.js. The setEncryptionOptions() method takes the encryption type that is set to STRONG_CRYPTOGRAPHIC_PROVIDER, however, you may use other options for instance ENHANCED_CRYPTOGRAPHIC_PROVIDER_V_1, XOR, or COMPATIBLE as per your needs. When we set the password string and save the workbook, Excel will ask for the same password before opening it.
This brief tutorial has guided us to password protect Excel file using Node.js. If you want to learn other features like deleting a pivot table in an Excel file, refer to the article on how to delete pivot table using Nodejs.