0

How to save Json array returned from backend into an Excel file in Angularjs?

This is the query connecting to backend. It is supposed to return an Excel file, but somehow it returns a Json array.

curl -o orders.xlsx --header "Authorization: xxxxxxx" --header "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" ''

I found this sample, http://jsfiddle.net/potatosalad/yuM2N/, but it does not do exactly what I need. In particular, it converts Json to String, and Json is not an array.

If I change the first three lines to

var data = [{a:1}, {b:2}, {c:3}];
var blob = new Blob([data], {type: "application/json"}); 

The output content is:

[object Object],[object Object],[object Object]
Luong Ba Linh
  • 802
  • 5
  • 20

0 Answers0