In this basic topic, you’ll learn how to Password Protect Excel File using NET REST API. We will create an application to encrypt Excel file using NET Cloud API by adhering to the detailed and lucid steps mentioned in the following section. The generated application can be integrated with any application supporting NET in macOS, Linux, or Windows environments and conversion can be done for free.
Prerequisite
- Create an account and get API credentials to password protect an XLS
- Download Aspose.Cells Cloud SDK for .NET to encrypt an XLS with password
- Setup C# .NET project with the above SDK to set password for the XLS file
Steps to Encrypt Excel File using NET Low Code API
- Configure the Client ID and Client Secret for the API to encrypt the Workbook with a password using NET REST API
- Instantiate the CellsApi class with client credentials to perform password protection of an XLS file
- Specify the source XLS file names and load the source XLS using a name and File object in a HashMap
- Instantiate the ProtectWorkbookRequest to set the password and other properties
- Create an instance of the PostProtectRequest to set the map files and ProtectWorkbookRequest instance
- Call the PostProtect request method to encrypt Excel file using NET low code API
- Save the password protected Excel file/s on the local disk
The above steps manage to password protect Excel using NET REST API. We will commence the process with the configuration of the SDK and creating the CellsAPI class instance. We will then open the source XLS files using a HashMap and instantiate the ProtectWorkbookRequest and PostProtectRequest classes that are further used for setting the password protection for the Excel files using the PostProtect() method.
Code for Password Protect Excel using NET REST API
This simple example code enables you password protect Excel using NET low code API. You should be providing the source Excel files and a password for the protection along with other optional properties. After creating the Request Message, PostProtect() performs the protection of the Excel file and returns the password-protected Excel files that can stored on the disk or inside the database.
We have explored to encrypt Workbook with Password using NET REST API in this article. If you want to explore Excel to PNG conversion, refer to the article on how to Convert Excel to PNG with NET REST API.