unprotect excel sheet

How to unprotect Excel(XLS, XLSX) using C# .NET

Excel worksheets are commonly used for managing and analyzing data in various industries. However, there are times when certain data or formulas need to be protected from accidental or intentional modifications. This is where password protection comes into play. Password protection allows users to restrict access or editing capabilities of their Excel worksheet. While this feature provides security to your data, it can also cause frustration when you need to make changes to a protected worksheet. In this article, we will show you how to unprotect Excel worksheets using C# .NET, giving you full control over your data once again.

API to Unprotect Excel

Aspose.Cells Cloud is a powerful and versatile API that allows you to work with Excel files. It also offers many benefits, including the ability to unprotect Excel worksheets. With its cross-platform compatibility, seamless integration, robust security, and cost-effectiveness, it is a great choice for developers looking to work with Excel files in the cloud. Aside from its unprotecting feature, Aspose.Cells Cloud offers a range of other benefits, including:

  • Cross-platform compatibility
  • Seamless integration: Integrate with Dropbox, Google Drive, and Amazon S3, allowing you to easily manage your Excel files.
  • Robust security: OAuth2 authentication and SSL encryption ensures data security.
  • Cost-effective: Flexible pricing options, where you only pay for the services you use.

Now in order to use Aspose.Cells Cloud SDK for .NET (which is a wrapper around Aspose.Cells Cloud), search Aspose.Cells-Cloud in NuGet packages manager and click the “Add Package” button. You also need to create an account over Dashboard using a valid email address.

Unprotect Excel Sheet using C#

In order to remove password from Excel worksheet, please try using the following code snippet.

Specified below are the details regarding above code snippet:

CellsApi cellsInstance = new CellsApi(clientID, clientSecret);

Create an object of CellsApi while passing client credentials as arguments.

WorkbookEncryptionRequest protection = new WorkbookEncryptionRequest();
protection.Password = "123456";
protection.KeyLength = 128;
protection.EncryptionType = "XOR";

Create an instance WorkbookEncryptionRequest holding workbook decrypt information

cellsInstance.UploadFile(input_Excel, File.OpenRead(input_Excel));

Upload encrypted Excel to cloud storage.

var response = cellsInstance.CellsWorkbookDeleteDecryptDocument(input_Excel, protection, folder);

Call the API to unprotect Excel and save output to cloud storage.

The encrypted Excel used in the above example can be downloaded from protected.xlsx.

Unlock Excel Sheet using cURL Commands

Accessing Aspose.Cells Cloud via cURL commands offers a flexible and simple way to work with the API. With cURL, you can use Aspose.Cells Cloud with any programming language or platform that supports cURL, providing flexibility in their development environment. Additionally, cURL is a lightweight tool that does not require any complex setup or installation, making it easy for developers to quickly integrate with the API. Therefore, by using cURL commands to interact with Aspose.Cells Cloud, you can streamline your workflows and improve productivity.

Now, you will need to have cURL installed on your system and then generate an accessToken based on client credentials:

curl -v "https://api.aspose.cloud/connect/token" \
-d "grant_type=client_credentials&client_id=bb959721-5780-4be6-be35-ff5c3a6aa4a2&client_secret=4d84d5f6584160cbd91dba1fe145db14" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"

Use the following command to upload input Excel to cloud storage:

curl -v "https://api.aspose.cloud/v3.0/cells/storage/file/{filePath}" \
-X PUT \
-F file=@{localFilePath} \
-H "Content-Type: multipart/form-data" \
-H "Authorization: Bearer {accessToken}"

Replace {filePath} with the path where you want to store the file in the cloud storage, {localFilePath} with the path of an Excel on your local system, and {accessToken} with your Aspose Cloud access token (generated above).

Finally, execute the following command to unprotect Excel sheet online:

curl -v "https://api.aspose.cloud/v3.0/cells/{excelFile}/encryption" \
-H  "accept: application/json" \
-H  "authorization: Bearer {accessToken}" \
-H  "Content-Type: application/json" \
-d "{  \"EncryptionType\": \"XOR\",  \"KeyLength\": 128,  \"Password\": \"123456\"}"

Replace {excelFile} with the name of the encrypted Excel file from cloud storage, {accessToken} with the access token generated above. After successful operation, the unprotected Excel will be stored in the same cloud storage.

Concluding Remarks

In this article, we have discussed how to unprotect Excel worksheets using Aspose.Cells Cloud, an API that provides an easy way to work with Excel files in the cloud. We have also highlighted the benefits of using Aspose.Cells Cloud, including cross-platform compatibility, seamless integration, robust security, and cost-effectiveness. Additionally, we have discussed the advantages of accessing Aspose.Cells Cloud via cURL commands, such as flexibility, simplicity, and improved productivity. By following the steps outlined in this article, you can easily unprotect Excel worksheets and automate the process of managing their Excel files. Overall, Aspose.Cells Cloud and cURL provide a powerful combination of tools for developers looking to work with Excel files in the cloud.

Please visit the following links to learn more about: