0

Referring to this Javascript JSON to Excel file download, I tried and successfully convert from JSON to XLSX. However the result is viewed in horizontal, the question is how to make it vertical? I just have only 1 long object data not multiple object. That why I prefer the result is in vertical for better view.

Horizontal View

enter image description here

Vertical View

enter image description here

Code:

var data = [{
    "Name": "Michael",
    "Place": "Home",
    }
]

filename='personal.xlsx'; 
var ws = XLSX.utils.json_to_sheet(data);
var wb = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, ws, "People");
XLSX.writeFile(wb,filename);
mastersuse
  • 936
  • 1
  • 15
  • 35

1 Answers1

0

I see you have object there, the only thing you need is to pivot it. this plugin may help you.

https://www.npmjs.com/package/json-to-pivot-json