Password Protect Excel spreadsheets

Are you looking to enhance the security of your Excel (XLS, XLSX) files? Password-protecting your files is an essential step to ensure your data stays confidential. In this basic guide, we’ll walk you through adding password protection to Excel files using the Excel Spreadsheet Password Protector REST API and its SDK for Python. Let’s get started!

Step 1: Installing Python Excel Spreadsheet Password Protector SDK

To begin with, install GroupDocs.Merger Cloud SDK for Python to your Python project with pip (package installer for Python) using the following command in the console:

pip install groupdocs-merger-cloud

Step 2: Initiate the API Client

Now, please get your Client ID and Client Secret from the dashboard and add the code as shown below:

Step 3: Uploading the Excel Spreadsheet

Before starting, it’s essential to upload the Excel file you wish to secure with a password. Employ any of the methods listed below to upload the document to your cloud storage:

  • Using the dashboard
  • Upload all files one by one using Upload File API from the browser
  • Upload programmatically using the code example given below:

As a result, the uploaded files will be available in the [files section][] of your dashboard on the cloud.

Step 4: Protect Excel Spreadsheet using Python SDK

The following steps and sample code shows how to password-protect Excel file using Python SDK.

  1. Set up API credentials (AppSID and AppKey).
  2. Create a SecurityApi instance with the provided credentials.
  3. Define options for adding a password to an Excel spreadsheet.
  4. Set the file path and password for the target document.
  5. Specify the output path for the protected document.
  6. Call the addPassword method with the option to add the password and save the result.

The following code example shows how to add a password to an Excel file using Python SDK.

Step 5: Download Password Protected Excel File

The code given in the previous step saves the Excel file on the cloud. To download it, you can use the following code snippet.


Congratulations! You’ve successfully added password protection to your Excel file using the Excel Spreadsheet Password Protector REST API and Python SDK. Your data is now secure and only accessible to those who know the password.

In this guide, we’ve covered the basic steps to get you started. The GroupDocs.Merger Cloud REST API offers a wide range of features for document manipulation, so feel free to explore its capabilities further. Happy coding!

Moreover, explore our API reference section which allows you to see and interact with our APIs directly through the browser. Python SDK’s complete source code is freely available on Github.

Finally, we keep writing new blog articles on different file formats and parsing them using REST API. So, please get in touch for the latest updates.

Free Online Password Protector

To password-protect Excel spreadsheet online for free. You can try our online Excel spreadsheet password protector app. This XLS/XLSX password creator app is developed using the above-mentioned Excel file password protector REST API.

Ask a question

In case you would have any queries or confusion about the Excel spreadsheet password protector REST API and Python SDK, please feel free to contact us via our forum.

See Also

Here are some related articles that you may find helpful: