I am using XLUtils (excellent library, thank you!) with a template xlsx file, adding data and populating a chart using the dynamic named ranges as explained in the 'Templates and Charts' tutorial.
My problem is that the number of series' of data is variable, so I can not know how many named ranges are needed:
For example:
Date | Data Set 1 | Data Set 2 | other data sets...... |
2022-02-01 | 5875 | 52254 | |
2022-02-02 | 9656 | 58758 | |
: other dates | | | |
Until the report is created I don't know how many data sets there will be.
To populate the chart, I need to create named ranges for date, and all the data sets. But without knowing how may data sets there will be, I can't.
I can get around this to some extent by creating more data set named ranges there there will ever possibly be. But obviously there's the question of how many to create, and doing that means that the key on the chart will have a lot of unused entries:
Is there a better way to solve this?