How to Get a Cell from an Excel Spreadsheet by Cell Identifier using Node.js

Cloudmersive
2 min readDec 1, 2023

--

If we’re looking to repeatedly extract specific pieces of data from our Excel worksheets, we can use a simple low-code API to automate that process in our Node.js applications.

Using the ready-to-run code examples provided below, we can leverage a free API designed to retrieve the value of a specific cell in our Excel document based on its cell identifier. Our API request parameters can look like the following JSON example:

{
"InputFileBytes": "string",
"InputFileUrl": "string",
"WorksheetToQuery": {
"Path": "string",
"WorksheetName": "string"
},
"CellIdentifier": "string"
}

Our API response will include the path to the cell we want, along with the text value, the cell identifier, the style index for that cell, and the formula applied within that cell (if applicable).

We can structure our request in a few quick steps, starting with SDK installation. We can install the SDK either by running the below command:

npm install cloudmersive-convert-api-client --save

Or by adding the following snippet to our package.json:

  "dependencies": {
"cloudmersive-convert-api-client": "^2.6.3"
}

With that out of the way, we can copy the below code into our file. To authorize our requests, we’ll need a free-tier API key; this will allow a limit of 800 API calls per month (with no commitment):

var CloudmersiveConvertApiClient = require('cloudmersive-convert-api-client');
var defaultClient = CloudmersiveConvertApiClient.ApiClient.instance;

// Configure API key authorization: Apikey
var Apikey = defaultClient.authentications['Apikey'];
Apikey.apiKey = 'YOUR API KEY';



var apiInstance = new CloudmersiveConvertApiClient.EditDocumentApi();

var input = new CloudmersiveConvertApiClient.GetXlsxCellByIdentifierRequest(); // GetXlsxCellByIdentifierRequest | Document input request


var callback = function(error, data, response) {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
};
apiInstance.editDocumentXlsxGetCellByIdentifier(input, callback);

That’s all there is to it — now we can retrieve specific Excel data with ease.

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

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

No responses yet