0

So technically i want to generate a csv using json2csv library and upon generating it wanted to download a file with a browser save dialog box such as below :

var csv = json2csv({ data: tableData.data, fields: fields });
var data = new Blob([csv], { type: 'text/plain;charset=utf-8' });
// Next : I want to download a file using a browser file dialog (wherein) i could change the filename
// FileSaver.saveAs(data, 'filename.csv'); 
// with this (above) i could download the file however I want the dialog box to open 

Basically the desired output is like a file downloaded from a server where the browser opens up a save file dialog box (name, path, extension.. etc)

Is this possible thru client-side only?

Solutions that I've tried : Create a file in memory for user to download, not through server this also just downloads the file without opening the save file dialog

CSV Library : www.mircozeiss.com/json2csv

FileSaver.js : https://github.com/eligrey/FileSaver.js

Victor Soto
  • 234
  • 3
  • 12
  • I believe that you're looking for [this](https://stackoverflow.com/questions/14964035/how-to-export-javascript-array-info-to-csv-on-client-side) solution. – Malisbad Nov 27 '17 at 23:58
  • Possible duplicate of [How to export JavaScript array info to csv (on client side)?](https://stackoverflow.com/questions/14964035/how-to-export-javascript-array-info-to-csv-on-client-side) – Goose Nov 07 '18 at 16:35

0 Answers0