Convert EXCEL to JSON and JSON to EXCEL in Node.js

How to Convert EXCEL to JSON and JSON to EXCEL in Node.js
Convert EXCEL to JSON and JSON to EXCEL in Node.js

Excel provides a wide range of features to keep and organize data in the form of worksheets contained by workbooks. In addition to the data organization, it lets you perform sorting, data visualization, mathematical computations and etc. In certain cases, you receive data in JSON format and you need to export it to Excel worksheets programmatically. For such cases, this article covers how to convert Excel to JSON and JSON to Excel in Node.js.

The following topics shall be covered in this article:

Excel to JSON and JSON to Excel Conversion REST API – Installation

In order to convert Excel to JSON and JSON to Excel, we will be using the Node.js SDK of GroupDocs.Conversion Cloud API. It is a platform-independent open-source library and document conversion solution. It allows you to seamlessly convert your documents and images of any supported file format to any format you need. You can easily convert between over 50 types of documents and images such as Word, PowerPoint, Excel, PDF, HTML, CAD, raster images, etc. It also provides .NET, Java, PHP, Ruby, Android, and Python SDKs as its document conversion family members 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:

  1. Upload the Excel file to the cloud
  2. Convert XLSX to JSON file
  3. Download the converted JSON file

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:

How to Convert XLSX to JSON using Node.js
Convert XLSX to JSON using Node.js

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:

How to Convert JSON to Excel Online using Node.js
How to Convert JSON to Excel Online using Node.js

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

See Also