I have a 3rd party service which supposes to return me an .xls By calling their API, I get a response similar to this:
Which I believe is a binary string (presented in Postman). The Content-Type is text/html; charset=utf-8
I need to convert it to .xls using node.js, so I try:
let arr = new Array();
for (var i = 0; i != request.data.length; ++i)
arr[i] = String.fromCharCode(request.data[i]);
let bstr = arr.join("");
var workbook = XLSX.read(bstr, {
type: "binary"
});
XLSX.writeFile(workbook, "output.xls");
This creates a file that opens without warnings, however, it does not display the contents correctly.
How can I create a valid .xls file from a given string using node.js? Why my solution is not working?