Microsoft Excel offers an extensive array of tools for maintaining and structuring data through worksheets within workbooks. Beyond data organization, it empowers users to execute tasks such as sorting, visualizing data, performing mathematical calculations, and more. In specific scenarios, data is received in JSON format, necessitating programmatic conversion to and from Excel worksheets. This article presents a guide on performing Excel to JSON and JSON to Excel conversions in Node.js.
The following topics shall be covered in this article:
- Excel to JSON and JSON to Excel Conversion REST API - Installation
- How to Convert Excel File to JSON Online in Node.js
- How to Convert JSON to Excel Online using Node.js
Excel to JSON and JSON to Excel Conversion REST API - Installation
To perform Excel-to-JSON and JSON-to-Excel conversions, we’ll utilize the Node.js SDK of GroupDocs.Conversion Cloud API. This API is an open-source, platform-agnostic library and document conversion solution that empowers you to effortlessly transform documents and images from any supported file format into your desired format. With this versatile tool, you can effortlessly switch between more than 50 document and image types, including Word, PowerPoint, Excel, PDF, HTML, CAD, raster images, and more. Additionally, it offers SDKs for .NET, Java, PHP, Ruby, Android, and Python, all of which are part of its document conversion family for the Cloud API.
You can install GroupDocs.Conversion cloud to your Node.js application using the following command in the console:
npm install groupdocs-conversion-cloud
Please get your Client ID and Client Secret from the dashboard before you start following the steps and available code examples. Once you have your ID and secret, please add in the code as shown below:
How to Convert Excel File to JSON Online in Node.js
You can convert Excel to JSON in NodeJS programmatically on the cloud by following the steps given below:
Upload the Excel File
Firstly, upload the Excel file to the cloud using the following code sample:
As a result, the uploaded Excel file will be available in the files section of your dashboard on the cloud.
Convert XLSX to JSON using Node.js
You can convert XLSX to JSON in Nodejs programmatically by following the steps as given below:
- Create an instance of the ConvertApi
- Create an instance of the ConvertSettings
- Set storage name and the input excel file path
- Assign “json” to the format
- Now, provide the output json file path
- Create ConvertDocumentRequest with ConvertSettings
- Convert by calling the convertDocument() method with ConvertDocumentRequest
The following code example shows how to convert Excel to JSON in Nodejs using REST API:
Download the Converted File
The above code sample will save the converted JSON file on the cloud. Now you know how to convert Excel to JSON in node. Next, download JSON file using the following code sample:
How to Convert JSON to Excel Online using Node.js
You can convert JSON to XLSX format programmatically by following the steps as given below:
- Create an instance of the ConvertApi
- Create an instance of the ConvertSettings
- Set storage name and the input JSON file path
- Assign “xlsx” to the format
- Now, provide the output xlsx file path
- Create ConvertDocumentRequest with ConvertSettings
- Convert by calling the convertDocument() method with ConvertDocumentRequest
Follow steps mentioned above to upload and download the converted file. The following code example shows how to convert JSON to Excel online in Nodejs using REST API:
Online Excel to JSON and JSONto Excel Converter Free
How to convert Excel to JSON online and JSON to Excel free? Please try the following to Excel to JSON converter online free and JSON to Excel converter online free, which is developed using the above API.
Conclusion
JSON files are immensely used to store and share the data among different applications. Often, you need to export data from JSON files to Excel worksheets. Accordingly, in this article, you have learned how to convert JSON to Excel XLSX or XLS in Node.js. Also, you have seen how to apply formatting in JSON to Excel conversion. In order to explore more about Aspose.Cells for Node.js via Java, visit the documentation. Furthermore, you can ask your questions via our forum.
Excel and JSON files are widely used to store and transmit the data. In accordance with that, this article covered how to turn XLSX into JSON in Node.js applications. Now you know:
- how to convert XLSX file to JSON online using Node.js;
- how to convert JSON file to XLSX format using Node.js;
- programmatically upload and download converted files;
- free Excel to JSON and JSON to Excel online converter;
Furthermore, you can learn more about GroupDocs.Conversion Cloud API using the documentation. We also provide an API Reference section that lets you visualize and interact with our APIs directly through the browser.
Ask a question
You can ask your queries about how to convert XLSX file into JSON format, via our Free Support Forum