Repair Corrupted Excel Files with Aspose.Cells Cloud API

Introduction

The Aspose.Cells Cloud API is a cloud-native REST API supporting repair of Excel (XLS/XLSX), CSV, and ODS files. In this article, we walk you through the process of using the Aspose.Cells Cloud API for file repair, including typical use cases and example code.

Overview

The Aspose.Cells Cloud API provides a robust interface for repairing corrupted Excel or other spreadsheet files. By leveraging the Aspose.Cells Cloud API, you can programmatically repair files, catering to a diverse range of requirements.

The API supports file repair and is generally compatible with various online environments. Below is a detailed description of the API:

How to repair Excel or another spreadsheet through Aspose.Cells Cloud

The Aspose.Cells Cloud API provides multiple SDKs for different programming languages. Choose the SDK that aligns with your preferred programming language and follow the accompanying documentation for installation and initialization. Alternatively, you can craft your own SDK according to the API reference. In this section, we’ll use C# as an example to detail the process of file repair.

Registration and Obtaining API Key

Before getting started, you need to register an Aspose Cloud account and obtain an API key for authentication. By logging into the official Aspose Cloud website, you can create a free account and obtain an API key for authentication purposes.

For more in-depth operations, please refer to the following documents: Quick Start with Cells Cloud

Installing and Initializing the Aspose.Cells Cloud SDK

Install the Aspose.Cells-Cloud NuGet package in your .NET project; you can use the NuGet Package Manager Console or the NuGet Package Manager in Visual Studio. Here’s how you can install the package using the Package Manager Console:


Install-Package Aspose.Cells-Cloud

Creates a new instance of the CellsApi class, initializing it with your client ID and client secret.


// Replace with your actual client ID and secret (from https://dashboard.aspose.cloud/applications)
CellsApi cellsApi = new CellsApi(
    Environment.GetEnvironmentVariable("ProductClientId"),
    Environment.GetEnvironmentVariable("ProductClientSecret")
);

Construct the API Request and Call the API

This creates a new instance of the PostRepairRequest, initializing it with your desired file format and files. It then calls the repair API with this repair request. The repaired function supports extended query parameters, too.


try
{
    CellsApi cellsApi = new CellsApi(
        Environment.GetEnvironmentVariable("ProductClientId"),
        Environment.GetEnvironmentVariable("ProductClientSecret")
    );
    Model.FilesResult result = cellsApi.PostRepair(
        new PostRepairRequest
        {
            File = new Dictionary<string, Stream>
            {
                { "NeedRepairedExcel.xlsx", System.IO.File.OpenRead("NeedRepairedExcel.xlsx") }
            }
        }
    );
    foreach (var file in result.Files)
    {
        File.WriteAllBytes(file.Filename, Convert.FromBase64String(file.FileContent));
    }
}
catch (ApiException e)
{
    Console.WriteLine("Error repairing file: " + e.Message);
}

Conclusion

With Aspose.Cells Cloud API, you can easily repair Excel or other spreadsheet files. By making simple API calls and setting appropriate repair options, you can efficiently fulfill various file repair requirements. Integrate Aspose.Cells Cloud API into your applications to enhance productivity and save development time.

Please note that the above example code is for demonstration purposes only, and you would need to replace it with valid authentication credentials and file paths when using it in practice. Additionally, Aspose.Cells Cloud API offers many other features, such as spreadsheet creation, editing, manipulation, and data processing. Detailed API documentation and example code can be found on the developer guide of the official Aspose website.

We hope this article helps you understand how to use Aspose.Cells Cloud API for file repair. Best of luck with your implementation!