Cloudmersive

Convert CSV to Excel in Ruby

The Comma Separated Values (CSV) format is ideal for capturing complex data sets, but it is not the easiest on the eyes. If you regularly need to convert CSV files to the more presentable and easy-to-manipulate XLSX format, we have a tool that can help with that. In this brief tutorial, we will demonstrate how you can use an API to automatically convert a CSV file to XLSX, allowing you to increase productivity by saving time on manual conversions.

First, you will add the Ruby client to your Gemfile:

gem 'cloudmersive-convert-api-client', '~> 2.1.6'

After the Ruby client is installed, you can call the conversion function with the following code:

# load the gem
require 'cloudmersive-convert-api-client'
# setup authorization
CloudmersiveConvertApiClient.configure do |config|
# Configure API key authorization: Apikey
config.api_key['Apikey'] = 'YOUR API KEY'
# Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
#config.api_key_prefix['Apikey'] = 'Bearer'
end

With the return of your new Excel file, your process will be complete!

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.