How to Convert ODS Spreadsheets to JPG Arrays using Node.js

Cloudmersive
2 min readNov 10, 2023

--

There’s no need to share or store bulky spreadsheet files in our system if a quick snapshot of our data does the trick.

We can use the below code to take advantage of a free ODS (Open Document Spreadsheet) to JPG conversion API within our Node.js applications. Not only can we make a seamless conversion with one image per page/worksheet of the original file, but we can also control the output quality of our JPG images by setting an integer between 1 (highest compression) and 100 (lowest compression).

To structure our request, let’s begin by installing the SDK. We can either choose to run the following command:

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

Or we can alternatively add the following snippet to our package.json:

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

After that, we can get ready to authorize our API requests by obtaining a free-tier API key from the Cloudmersive website. These allow a limit of 800 API calls per month with no commitment, so they’re perfect for small-scale or experimental projects.

With our API key ready to go, let’s now include the below code in our file & configure our request:

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.ConvertDocumentApi();

var inputFile = Buffer.from(fs.readFileSync("C:\\temp\\inputfile").buffer); // File | Input file to perform the operation on.

var opts = {
'quality': 56 // Number | Optional; Set the JPEG quality level; lowest quality is 1 (highest compression), highest quality (lowest compression) is 100; recommended value is 75. Default value is 75.
};

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

That’s all there is to it — no more code required!

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

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

No responses yet