init script to download exctract csv

This commit is contained in:
redup nomade 2016-12-06 10:59:22 +01:00
parent 60e22cf78e
commit 3ec7259be6

23
scriptDownload.js Normal file
View file

@ -0,0 +1,23 @@
var A = [['n','sqrt(n)']];
for(var j=1; j<5; ++j){
A.push([j, Math.sqrt(j)]);
}
var csvRows = [];
for(var i=0, l=A.length; i<l; ++i){
csvRows.push(A[i].join(','));
}
var csvString = csvRows.join("%0A");
var a = document.createElement('a');
var linktext = "Scarica la scheda e mettila al sicuro";
a.href = 'data:attachment/csv,' + csvString;
a.target = '_blank';
a.download = 'schedaProduzione.csv';
a.innerHTML = linktext;
document.body.appendChild(a);//mette un anchor per fartelo scaricare
// a.click(); simula il click al caricamento della pagina