How to Convert CSV to Excel using REST API in Node.js

Convert CSV to Excel using REST API in Node.js

CSV or comma-separated values is the most flexible data format, used to import and export data between different spreadsheet programs. It can be opened by most data upload interfaces and applications. While Excel (XLS and XLSX) file format is used to store complex tabular data. If you want to exchange your data between programs, import and export it from one application to another then the CSV file format is the best option. Today, we will learn how to convert CSV to Excel using REST API in Node.js. In an earlier post, we have seen how to convert Excel to CSV format using REST API in Node.js.

The following topics shall be covered in this article:

CSV to Excel Conversion REST API and Node.js SDK

In order to convert CSV to Excel file format is using the Node.js SDK of GroupDocs.Conversion Cloud API. It is a platform-independent Nodejs document conversion library. 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 project 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 CSV to Excel file using REST API in Node.js

You can convert csv to xls/xlsx format in nodejs programmatically on the cloud by following the steps given below:

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

Upload the CSV 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 CSV to XLSX format in Node.js

You can convert csv to excel xlsx 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 “csv” to the format
  • Now, provide the output csv file path
  • Create ConvertDocumentRequest with ConvertSettings
  • Convert by calling the convertDocument() method with ConvertDocumentRequest

The following code example shows how to convert CSV to Excel file in Nodejs using REST API:

Download the Converted File

The above code sample will save the converted CSV file on the cloud. Now you know how to convert CSV to Excel in nodejs. Next, download excel file using the following code sample:

Free CSV to Excel Converter Online

How to convert CSV to Excel online free? Please try the following to convert CSV to Excel online free, which is developed using the above API.

Conclusion

CSV and Excel files are widely used to store and transmit the data. In accordance with that, this article covered how to change CSV to XLSX file in Node.js applications. Now you know:

  • how to convert CSV to XLSX using Node.js;
  • programmatically upload CSV and then download the converted Excel file;
  • free online CSV to excel 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 CSV to Excel format, via our Free Support Forum

See Also