I have an object like this:
obj = {'a': [1, 2, 3], 'b': [0, 0,0], 'c': [1, 0, 4]}
I display it in a html table like this:
Code | sum1 | sum2 | sum 3
a | 1 | 2 | 3
b | 0 | 0 | 0
c | 1 | 0 | 4
And I want to export this table into excel. This is my code:
export() {
let w = new Workbook();
let ws = w.addWorksheet('Sheet 1');
ws.addRow(['Code', 'sum1', 'sum2', 'sum3'])
for (let i = 0; i < this.obj['a'].length; i++) {
ws.addRow(['a', this.obj['a'][i]])
}
for (let i = 0; i < this.obj['a'].length; i++) {
ws.addRow(['b', this.obj['b'][i]])
}
for (let i = 0; i < this.obj['a'].length; i++) {
ws.addRow(['c', this.obj['c'][i]])
}
}
but this won't add the objects on rows, but on columns(something like this:)
Code | sum1 | sum2 | sum3
a | 1 | |
a | 2 | |
a | 3 | |
b | 0 | |
b | 0 | |
b | 0 | |
c | 1 | |
c | 0 | |
c | 4 | |
How can I solve this? Thank you for your time!