I would suggest that you do not add columns to the table at runtime. Instead you have two possibilities.
1. You can decide the amount of columns beforehand. Loop through the data and see how many columns you need. Then when adding the data, leave the empty values in in the insert statement as
null
.
2. Re-model you database structure. Instead of storing the data in Excel columns as DB columns, transpose the data to be rows. This would mean that you would have table something like (pseudo definition):
- rownumber
- columnnname
- value
So the rows from your example could be:
rownumber columnname value
--------- ---------- -----
1 a 1
1 b 2
1 c 3
2 a 2
2 b 4
...
4 a 1
4 b 2
4 c 3
4 d 5
4 e 6
...