2

I have a 3rd party service which supposes to return me an .xls By calling their API, I get a response similar to this:

enter image description here

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.

created .xls file

How can I create a valid .xls file from a given string using node.js? Why my solution is not working?

Yuriy P.
  • 111
  • 8

0 Answers0