The encoding in which to save the data in excel?

0 like 0 dislike
151 views
Welcome!
There is a RestAPI which provides data excel (. xlsx) in the form of a query:

request.post( rest_url+"/basecoefficient/getReport", { json: true, body: req.body.data, headers: { 'content-type' : "application/json; charset=utf-8", 'Authorization': "Bearer" + req.body.token } } , function(err, response, body) { console.log(response.body) return res.json(response) });


In response.body come data excel (. xlsx) file in UTF:

PK\\u0003\\u0004\\u0014\\u0000\\b\\b\\b\\u0000\\u000b�DN\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u000b\\u0000\\u0000\\u0000_rels/.rels���j�0\\f�_���8�`�Q��2�m��\\u00014[ILb��ږ���.[K\\\u001b�($}�\\u0007�v?�I�Q.���I�h���\\u001bx>=��@\\u0015��p�H\\u00


When saving in this format does not open the file because the data is in the UTF. How to convert UTF recognizable in excel (xlsx) format?
by | 151 views

1 Answer

0 like 0 dislike
Apparently, you binary data as json processing.
I would reconsider, in principle, the downloading of the report - I would not return data but return a link where you can download the file.

In General terms, your POST request builds excel and saves it in the file system. The output is a link to it, it is given to the customer.
The client clicks the link (a redirect is the same, for example), the file is downloaded and deleted from the server.
by

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
3 answers
0 like 0 dislike
3 answers
0 like 0 dislike
2 answers
0 like 0 dislike
2 answers
110,608 questions
257,187 answers
0 comments
40,796 users