admin管理员组

文章数量:1391987

I am using EXT JS 4.2 which has a panel which contains a export to CSV button.

On clicking on it multiple (total six) files are downloaded. I want these files to be downloaded in a single ZIP file.

I am using EXT JS 4.2 which has a panel which contains a export to CSV button.

On clicking on it multiple (total six) files are downloaded. I want these files to be downloaded in a single ZIP file.

Share Improve this question edited Feb 3, 2017 at 17:00 Prateek Ratnaker asked Feb 23, 2016 at 14:12 Prateek RatnakerPrateek Ratnaker 8171 gold badge11 silver badges35 bronze badges 2
  • Have you tried to create a folder using JSZip? – André Bonna Commented Feb 23, 2016 at 18:34
  • I created a JSFiddle that works. Hope it helps! – André Bonna Commented Feb 23, 2016 at 20:10
Add a ment  | 

1 Answer 1

Reset to default 6

There is a perfect plugin to create zip files inside browser.

JSZip: https://stuk.github.io/jszip/

Install the plugin by adding js files manually:

download JSZip and include the file dist/jszip.js or dist/jszip.min.js

JSFiddle - JSZip 3.0:

https://jsfiddle/andrebonna/u8zsbzau/

var zip = new JSZip();
for (var i = 0; i < 5; i++) {
    var CSV = 'CSV_content';
    // Fill CSV variable
    zip.file("file" + i + ".csv", CSV);
}

zip.generateAsync({
    type: "base64"
}).then(function(content) {
    window.location.href = "data:application/zip;base64," + content;
});

本文标签: extjsDownloading multiple files into a Zip file Javascript using data URIStack Overflow