Get Macros from an Excel File in Node.JS

Cloudmersive
2 min readMar 17, 2021

Due to their widespread use in data collection/manipulation, Excel documents are prime candidates for leveraging macros. Macros can perform a wide range of operations such as data and text manipulation, style and formatting application, database connection — and that’s just the tip of the iceberg. If you need to find out what macros are in an Excel file, we have an API that can help with that. The following instructions will lead you through how to retrieve macro information from an XLSX worksheet or spreadsheet using an API in Node.JS.

To begin, we will first install the client by running this command:

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

Or, you can add this snippet to your package.json:

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

Now that we’ve installed the SDK, we can call the get macros function with the following code:

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 inputFile = Buffer.from(fs.readFileSync("C:\\temp\\inputfile").buffer); // File | Input file to perform the operation on.var callback = function(error, data, response) {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
};
apiInstance.editDocumentXlsxGetMacroInformation(inputFile, callback);

And just like that, you will have your macro info. To retrieve your personal API key, head to the Cloudmersive website to register for a free account; this will give you access to 800 calls/month across our entire library of APIs.

--

--

Cloudmersive

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