How to get columns from a Excel XLSX spreadsheet in Node.JS

Our goal for this less seems simple: to get the columns from an XLSX file and to do so using Node.JS. While it seems straightforward, the actual process of manual implementation is chock full of headaches and time sinks. So let’s skip all that and give you the functionality that you need right now.

Our API client can be imported via this reference for our package.json.

"dependencies": {
"cloudmersive-convert-api-client": "^2.1.6"

Following that, we just need to call editDocumentXlsxGetColumns using an API instance, like so:

var CloudmersiveConvertApiClient = require('cloudmersive-convert-api-client');var defaultClient = CloudmersiveConvertApiClient.ApiClient.instance;// Configure API key authorization: Apikeyvar Apikey = defaultClient.authentications['Apikey'];Apikey.apiKey = 'YOUR API KEY';// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)//Apikey.apiKeyPrefix = 'Token';var apiInstance = new CloudmersiveConvertApiClient.EditDocumentApi();var input = new CloudmersiveConvertApiClient.GetXlsxColumnsRequest(); // GetXlsxColumnsRequest | Document input requestvar callback = function(error, data, response) {if (error) {console.error(error);} else {console.log('API called successfully. Returned data: ' + data);}};apiInstance.editDocumentXlsxGetColumns(input, callback);

And it’s really just that easy. Put in your request and moments later, boom! You have your column data. There are more functions in this library for working with Excel files, such as filling in cells and merging files.

Image for post

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

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store