How can we generate an Excel sheet using data of an Json object and generate a Pop up window for download.
Asked
Active
Viewed 2,004 times
0
-
simply serve a TSV or CSV or plain HTML table under an an excel mime type. downloadify and others can build the download without a server. – dandavis Jun 06 '14 at 20:55
-
1Something like this? https://stackoverflow.com/questions/17126453/html-table-to-excel-javascript/17129220#17129220 – Yuriy Galanter Jun 06 '14 at 20:57
1 Answers
0
You can use Excel Builder framework which works fine in Firefox not sure about IE 9...
Probably something like this....
var jsonData = [
['junk', 'data', 'for'],
['generating', 'excel', 'in'],
['java', 'script', ' ']
];
require(['excel-builder.js/excel-builder', 'download'], function (EB, downloader) {
var JSworkBook = EB.createWorkbook();
var JSworkSheet = JSworkBook.createWorksheet({name: 'Sheet'});
JSworkSheet.setData(jsonData);
JSworkBook.addWorksheet(JSworkSheet);
var data = EB.createFile(JSworkBook);
downloader('Artist WB.xlsx', data);
});
You can generate file download using downloadify
<script type='text/javascript'>
Downloadify.create('domElementId',{
filename: function(){
return //The filename
},
data: function(){
return EB.createFile(workbook)
},
swf: 'path/to/media/downloadify.swf',
downloadImage: 'path/to/images/download.png',
width: 100,
height: 30,
transparent: true,
append: false
});
</script>

Eric Brown
- 13,774
- 7
- 30
- 71

Nayeem
- 681
- 15
- 35