How to Convert ODS to XLSX in C/C++
If your organization is looking to conserve some money, the OpenOffice platform is a great option that allows free access to intuitive and user-friendly programs. One such program is OpenDocument Spreadsheet, which is comparable to Excel regarding data manipulation and editing capabilities but can be problematic when sharing with clients who utilize the full Office suite. The following API will allow you to ensure compatibility while keeping costs low by converting your ODS files to XLSX using C/C++.
To begin we will install libcurl in your C/C++ project:
libcurl/7.75.0
Next, we are going to configure the API key and call the function with the following 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/ods/to/xlsx");
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);
In no time at all, you will have an Excel file available for sharing; easy and stress-free conversion complete.