How to Convert XLSX to XML in Node.js

Cloudmersive
2 min readDec 20, 2022

--

While XLSX is based on XML, these formats unfortunately can’t be used interchangeably; the former is a proprietary, limited data type incorporating ZIP compression to reduce size, while the latter is an open standard.

Thankfully, you can quickly & easily convert your XLSX files to open standard XML using the below Node.js code — simply follow instructions to copy & paste examples, include a free-tier API key (register a free account here to get one), and you’re finished in a matter of minutes.

Let’s start by installing the SDK. Copy & run the below command:

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

We can alternatively install by adding this snippet (below) to our package.json:

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

Lastly, we can call the function with the below 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.ConvertDataApi();

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.convertDataXlsxToXml(inputFile, callback);

That’s all there is to it!

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

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

No responses yet