excel to json

Convert Excel to JSON using C# .NET

In today’s fast-paced business world, efficient data management is key to staying ahead of the competition. Therefore, the data has become a valuable commodity and its proper management is crucial for organizations of all sizes. One important aspect of data management is data conversion, which involves transforming data from one format to another to make it more usable and accessible. With the increasing demand for data conversion, it has become imperative for developers to have a reliable and efficient solution that can handle a wide range of conversion tasks. This technical blog will introduce a cutting-edge solution for Excel to JSON conversion and describe its features, benefits, and capabilities, providing a comprehensive overview of this solution and its applications.

Introduction to Excel to JSON Conversion API

One of the most important aspects of data management is converting data from one format to another, and this is where the Aspose.Cells Cloud SDK for .NET comes in. With its powerful and flexible features, this cloud-based API provides a simple and efficient solution for converting Excel spreadsheets into JSON format. Whether you’re a software developer looking to automate your data conversion tasks, or a business user needing to quickly convert spreadsheets for use in web or mobile applications, Aspose.Cells Cloud SDK for .NET offers a reliable and convenient solution. We are going to further explore the capabilities of the API, and going to show the steps to perform an Excel to JSON conversion with ease.

In order to use the SDK, we need to add its reference as a NuGet package. Search “Aspose.Cells-Cloud” in NuGet package manager and add the package.

Aspose.Cells Cloud

Image 1:- Aspose.Cells Cloud NuGet package.

Furthermore, we also need to have a Cloud dashboard account. In case you do not have an existing account, please create a free account over Cloud Dashboard using valid email address and obtain your personalized client credentials.

Excel to JSON using C#

This section explains all the necessary details on how to convert Excel to JSON using C# code snippet. Please note, this example uses input.xls worksheet.

excel to json

Image 2:- Excel to JSON conversion preview.

Now let’s try to understand the above code snippet:

CellsApi instance = new CellsApi(clientID, clientSecret);

Create an instance of CellsApi while passing the client credentials as arguments.

var file = System.IO.File.OpenRead(name)

Read the input Excel worksheet using OpenRead(…) method of the System.IO.File class.

instance.CellsWorkbookPutConvertWorkbook(file, format: format, outPath: resultantFile);  

Call the method to perform Excel to JSON conversion and save the output in Cloud storage.

XLS to JSON using cURL Commands

We understand that cURL is a command line tool for accessing REST APIs, making it an essential tool for developers and IT professionals. With cURL, we can make HTTP requests to REST APIs, retrieve data from servers, and perform various tasks. Now in this section, we are going to convert XLS to JSON using cURL commands.

Now, as a prerequisite, we need to first generate a JWT access token (based on client credentials) using the following command.

curl -v "https://api.aspose.cloud/connect/token" \
-X POST \
-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"

The following command expects the input XLS to be available in cloud storage and after conversion, we are going to save it on local drive.

curl -v -X GET "https://api.aspose.cloud/v3.0/cells/output.xls?format=JSON&isAutoFit=false&onlySaveTable=false&checkExcelRestriction=true" \
-H  "accept: application/json" \
-H  "authorization: Bearer <JWT Token>
-o "Converted.json"

In case we need to load the input XLS from Cloud storage and after conversion to JSON, we need to directly save the output in same cloud storage, then please try using the following command.

curl -v -X GET "https://api.aspose.cloud/v3.0/cells/output.xls?format=JSON&isAutoFit=false&onlySaveTable=false&outPath=converted.json&checkExcelRestriction=true" \
-H  "accept: application/json" \
-H  "authorization: Bearer <JWT Token>

Quick Tip

Looking for free Excel to JSON Converter ! Please try using our online Excel Converter.

Concluding Remarks

In conclusion, Aspose.Cells Cloud SDK for .NET is a powerful and flexible solution for converting Excel spreadsheets to JSON format. With its cloud-based architecture, easy-to-use interface, and advanced features, this API provides a convenient and efficient way to perform data conversion tasks, regardless of whether you’re a software developer or a business user. Whether you need to convert a single spreadsheet or multiple spreadsheets at once, Aspose.Cells Cloud SDK for .NET offers a reliable and efficient solution. By using this API, you can streamline your data conversion tasks, save time and resources, and focus on more important aspects of your business.

We highly recommend exploring the Product Documentation, which contains a huge collection of topics explaining other exciting features of the API. Lastly, if you encounter any issue while using the API, or you have any related query, please feel free to contact us via the free Product Support Forum.

Please visit the following links to learn more about: