How to get rows and cells from an Excel XLSX spreadsheet in Node.JS
Today we will be using Node.JS to extract a list of rows and cells from an XLSX file. This is normally a matter of buckling down for a few hours to laboriously code out and test our solution. Well, that’s not how we are doing it today. Instead we are going the easy route: I’m going to show you how to use an API to get this done in a couple of minutes instead.
Installing the Cloudmersive Convert Client comes first:
npm install cloudmersive-convert-api-client --save
Now we can set up a new instance of our API, which will allow us to call editDocumentXlsxGetRowsAndCells. Here’s an example of how that works.
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.GetXlsxRowsAndCellsRequest(); // GetXlsxRowsAndCellsRequest | Document input requestvar callback = function(error, data, response) {if (error) {console.error(error);} else {console.log('API called successfully. Returned data: ' + data);}};apiInstance.editDocumentXlsxGetRowsAndCells(input, callback);
And just like that, we are already done with our implementation. Super easy.