Advertisement
evg_rz_gf

ExportCSV

Nov 18th, 2019
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const BOM = '\ufeff';
  2. const TYPE = 'text/csv';
  3.  
  4. class CSV {
  5.     download( content = '', name = 'test.csv' ) {
  6.         let blob = new Blob( [ BOM + content ], { type: TYPE } );
  7.  
  8.         let link = document.createElement( 'a' );
  9.         link.href = window.URL.createObjectURL( blob );
  10.         link.download = name + '.csv';
  11.         link.click();
  12.     }
  13. }
  14.  
  15. export { BOM, TYPE };
  16. export default new CSV();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement