convert excel to json

Learn how to convert Excel to JSON using .NET Cloud SDK.

The need to convert Excel files to JSON has become increasingly paramount. Excel, with its tabular structure, is a go-to format for organizing and storing vast datasets. However, in the era of web applications, APIs, and diverse data interchange formats, the demand for more flexible and lightweight data representations is on the rise. This is where the conversion from Excel to JSON plays a pivotal role. This article delves into the significance of XLS to JSON conversion using .NET REST API and bridges the gap between traditional spreadsheet formats and the modern JSON data format.

.NET REST API for Excel to JSON Conversion

Converting Excel to JSON becomes a streamlined process with the versatile capabilities of Aspose.Cells Cloud SDK for .NET. Leveraging this powerful SDK, you gain access to a wealth of features that simplify and enhance the conversion journey. Therefore, with a few straightforward API calls, you can seamlessly transform Excel worksheets into structured JSON data.

Now, in order to leverage the capabilities of this SDK in .NET application, first we need to search Aspose.Cells-Cloud in NuGet packages manager and click the Add Package button. Secondly, obtain your client credentials from cloud dashboard. If you do not have an existing account, simply create a free account by following the instructions specified in the quick start article.

Convert XLS to JSON in C# .NET

Whether you’re dealing with complex spreadsheets or straightforward data sets, the SDK ensures efficiency, accuracy, and ease of integration into your .NET applications. So in this section, we are going to convert an XLS to JSON format using C# .NET.

CellsApi cellsInstance = new CellsApi(clientID, clientSecret);

Create an object of CellsApi class where we pass client credentials as arguments.

using (var file = System.IO.File.OpenRead(input_CSV))

Read the content of input Excel workbook into stream instance.

cellsInstance.CellsWorkbookPutConvertWorkbook(file, format: "JSON", outPath: resultant_file);

Finally, call the API to convert Excel workbook to JSON and upload the resultant file to cloud storage.

excel to json converter

A preview of Excel to JSON conversion.

The input Excel workbook and the resultant JSON file generated above can be downloaded from:

Converting XLSX to JSON using cURL Commands

Another interesting option for seamless conversion of XLSX to JSON, that can easily integrates into your workflow is a powerful combination of Aspose.Cells Cloud and cURL commands. The flexibility provided by Aspose.Cells Cloud API allows you to interact with the service through simple cURL commands, offering a scriptable solution that transcends platforms.

The first step in this approach is to generate a JWT access token using the following command:

curl -v "https://api.aspose.cloud/connect/token" \
 -X POST \
 -d "grant_type=client_credentials&client_id=921363a8-b195-426c-85f7-7d458b112383&client_secret=2bf81fca2f3ca1790e405c904b94d233" \
 -H "Content-Type: application/x-www-form-urlencoded" \
 -H "Accept: application/json"

Now, please execute the following command to convert an XLSX to JSON format. Please note that the following request method requires the input Excel workbook to be already available in the cloud storage.

curl -v "https://api.aspose.cloud/v3.0/cells/{sourceFile}?format=JSON&isAutoFit=true&onlySaveTable=true&outPath={output}&checkExcelRestriction=true" \
-X GET \
-H  "accept: application/json" \
-H  "authorization: Bearer {accessToken}" \
-d {}

Replace sourceFile with the name of source Excel workbook, output with the name of resultant JSON file and accessToken with a JWT access token generated above.

Conclusion

In conclusion, the capability to convert XLSX to JSON either using Aspose.Cells Cloud SDK for .NET or by using Aspose.Cells Cloud, coupled with cURL commands, stands as a fundamental asset in modern data processing workflows. This feature not only bridges the gap between Excel and JSON, but also unlocks a realm of possibilities for seamless integration and data interchange. Nonetheless, this feature also empowers you to adapt to evolving data requirements, streamline collaboration, and enhance the versatility of their applications.

We highly recommend visiting the following blogs: