I am creating one array dynamically.Following array is one example.
textarray = [["label first","details of label 1"],["label sec","details of label 2"],["label 3","details of label 3"],["label 4","details of label 4 and 3"],["label 5","details of label 5"],["label 6","details of label 6"],["label 7","details of label 7"],["label 8","details of label 8"],["label 9","details of label 9"]]
My ultimate goal is onclick on save button array will be generated and it should ask me for save/open in EXCEL format. So i have written something like this,
var a = document.createElement('a');
a.href = 'data:attachment/csv;charset=utf-8,' +textarray;
a.target = '_blank';
a.download = 'myFile.csv';
document.body.appendChild(a);
a.click();
I am getting prompt to save or open csv file but if i open that file, contents are not as expected(not showing properly)
It is coming like this,
**column1** **column2** ...........
**row1** labelfirst detailsoflabel1 labelsec detailsoflabel2
One row should contain only one element and if you see the above output there is no space in between words(see the array). It should be like this,
**column1** **column2**
**row1** label first details of label 1
**row2** label sec details of label 2
.
.
.
Please help me.