convert json to Excel workbook

How to convert JSON to Excel workbook using .NET Cloud SDK.

JSON is renowned for its flexibility in representing structured data, but often we require its translation into the Excel format for more sophisticated visualization, analysis, and sharing. This conversion is pivotal in bridging the gap between dynamic, web-based data structures and the comprehensive capabilities offered by Excel spreadsheets. Furthermore, as businesses grapple with vast amounts of diverse data, the importance of seamlessly transforming JSON into Excel lies in fostering a more accessible, organized, and visually intuitive representation. Let’s explore the details on how we can dynamically convert JSON to XLS or XLSX format using .NET Cloud SDK.

.NET Cloud SDK for JSON to Excel Conversion

The conversion of JSON to Excel becomes a seamless process with the robust capabilities of Aspose.Cells Cloud SDK for .NET. By leveraging this API, you can effortlessly upload your JSON data to the cloud storage, initiating a dynamic conversion to Excel format with a simple API call. The versatility of Aspose.Cells Cloud allows a precise control over the Excel output, ensuring a tailored representation of the 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 JSON to XLS in C# .NET

This section explains the details on how the API can facilitate in JSON to XLS conversion for informed decision-making and enhanced data visualization.

CellsApi cellsInstance = new CellsApi(clientID, clientSecret);

Firstly, create an object of CellsApi class where we pass client credentials as arguments.

cellsInstance.UploadFile("sourceFile.json", file);

Upload the input JSON file to cloud storage.

cellsInstance.CellsWorkbookGetWorkbook("sourceFile.json", format: "XLS", isAutoFit: true, outPath: resultant_file);

Finally, call the API to convert JSON to Excel. After successful conversion, the resultant Excel workbook is stored in cloud storage.

json to excel online

A preview of JSON to Excel workbook conversiond.

The sample JSON file used in the above example can be downloaded from:

JSON to Excel using cURL Commands

Converting JSON to Excel using Aspose.Cells Cloud and cURL commands provides a flexible and scriptable solution. The cURL commands serve as an efficient bridge, seamlessly connecting your application to the powerful capabilities of Aspose.Cells Cloud. Furthermore, this method not only simplifies the integration of Aspose.Cells Cloud into various development environments but also ensures a consistent and reliable process for transforming JSON data into visually appealing and structured Excel sheets.

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"

Once we have JWT token, please execute the following command to export JSON to XLS worksheet.

curl -v "https://api.aspose.cloud/v3.0/cells/{sourceFile}?format=XLS&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 input JSON file available in Cloud storage, output with the name of resultant XLS worksheet to be generated and accessToken with a JWT access token generated above.

Conclusion

In conclusion, the process of converting JSON to Excel unfolds as a dynamic journey, offering developers two robust pathways (one through the Aspose.Cells Cloud API with .NET and the other via cURL commands). Whether opting for the feature-rich environment of .NET or the simplicity of cURL commands, both avenues underscore the significance of translating JSON’s flexible data structure into the organized and visually intuitive realm of Excel.

We highly recommend visiting the following blogs: