Download .csv with javascript -


i want generate .csv in javascript. have object, name "archivo". problem when generate file csv, in each line add ',', don't know happen

archivo=[], each line string + '\n'.  if (navigator.appname == 'microsoft internet explorer') {                         var popup = window.open('','csv','');                  popup.document.body.innerhtml = '<pre>' + archivo[i] + '</pre>';                       }else{                location.href='data:application/download; charset=utf8,' + encodeuricomponent(archivo);             } 

any can me?

you should consider using csv generator library, handles you.

i've written light-weight client-side csv generator library might come in handy. check out on http://atornblad.se/github/ (scroll down headline saying client-side csv file generator)

it requires functioning filesaver implementation handling calls window.saveas(). check out eli grey's solution on http://eligrey.com/blog/post/saving-generated-files-on-the-client-side

when in place, generate , save csv files on fly this:

var propertyorder = ["name", "age", "height"];  var csv = new csv(propertyorder);  csv.add({ name : "anders",           age : 38,           height : "178cm" });  csv.add({ name : "john doe",           age : 50,           height : "184cm" });  csv.saveas("people.csv"); 

Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -