Blame view
src/vendor/Export2Zip.js
602 Bytes
d7d9c38c2 auto commit the c... |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
/* eslint-disable */ import { saveAs } from 'file-saver' import JSZip from 'jszip' export function export_txt_to_zip(th, jsonData, txtName, zipName) { const zip = new JSZip() const txt_name = txtName || 'file' const zip_name = zipName || 'file' const data = jsonData let txtData = `${th}\r ` data.forEach((row) => { let tempStr = '' tempStr = row.toString() txtData += `${tempStr}\r ` }) zip.file(`${txt_name}.txt`, txtData) zip.generateAsync({ type: "blob" }).then((blob) => { saveAs(blob, `${zip_name}.zip`) }, (err) => { alert('导出失败') }) } |