Get Macros from an Excel File in C/C++

Macros are a series of commands that can be used to automate everyday tasks, and can be formatted to support various purposes and industries. While most macros have some security features built in to their design, there is still a chance that externally received files may have malicious macros embedded in their code. To protect your system from these potential threats, you can run the following API in C/C++ to extract macro information from an Excel file.

To perform the operation, you will first need to Install libcurl:

libcurl/7.75.0

Once the installation is complete, you can call the function with the below code:

CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(curl, CURLOPT_URL, "https://api.cloudmersive.com/convert/edit/xlsx/get-macros");
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Content-Type: multipart/form-data");
headers = curl_slist_append(headers, "Apikey: YOUR-API-KEY-HERE");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_mime *mime;
curl_mimepart *part;
mime = curl_mime_init(curl);
part = curl_mime_addpart(mime);
curl_mime_name(part, "inputFile");
curl_mime_filedata(part, "/path/to/file");
curl_easy_setopt(curl, CURLOPT_MIMEPOST, mime);
res = curl_easy_perform(curl);
curl_mime_free(mime);
}
curl_easy_cleanup(curl);

The results that are returned will allow you to determine if you want to enable or disable macros in the document. Visit the Cloudmersive website to obtain your API key by registering for a free account; this provides 800 monthly calls across our entire library of APIs.

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