Since there is so much going in the documentation I can't seem to figure out a straightforward way of implementing this feature in my node-react app:
The API for my project is serving me array of objects containing data in json format page wise. Means, to get the entire data I have to make recursive get calls to the api like this: request.get(/contacts/page/(1...blank response page) and keep on concatenating data in a variable.
Now, I want to be able to convert this json data stored in a variable to a .xlsx file and make it available as a download or download concurrently as the data is fetching from the api.
I just need help in figuring out the steps for this process and nothing else. Thanks!
Supposing that data is an array of JS objects (request, JSON.parse, append to an array), you need to build the workbook then generate a download. The json_to_sheet utility does the hard part:
/* make the worksheet */
var ws = XLSX.utils.json_to_sheet(data);
/* add to workbook */
var wb = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, ws, "People");
/* write workbook */
var buf = XLSX.write(wb, {bookType:'xlsx', type:'buffer'}); // generate a nodejs buffer
var str = XLSX.write(wb, {bookType:'xlsx', type:'binary'}); // generate a binary string in web browser
See the discussion in https://github.com/SheetJS/js-xlsx/issues/817 for longer explanation as well as a sample jsfiddle and a sample runkit
I am able to work on it and it is downloadable but my requirement is to put some title on top as well .
Requirement is like following format : -
Please have a look on this ,

How can i achieve that ? I am getting only data set not title ,
The file which is downloaded from js code using node-excel-export npm is not readable using xlsx-to-json npm .how can i read sheetjs file
Most helpful comment
Supposing that
datais an array of JS objects (request, JSON.parse, append to an array), you need to build the workbook then generate a download. Thejson_to_sheetutility does the hard part:See the discussion in https://github.com/SheetJS/js-xlsx/issues/817 for longer explanation as well as a sample jsfiddle and a sample runkit