How to manage the table component of a report when column number can change at runtime

Hi folks, I have this controversial question that I can’t solve.
In my project, I show the table with a number of columns that can change during the runtime operation.
The operator has to print this information at runtime and I have made a report showing all the information
using table and graph. What is the smarter way to manage the table in my report to dynamically fit the table as the number of columns in the dataset that I pass to it changes? I don’t think many develop
report is the smartest solution, but I can’t figure out what to do on my report to make it dynamic in this situation!

https://docs.inductiveautomation.com/display/DOC81/Report+-+Simple+Table
maybe idk i’ve not realy done alot with reports yet

This approach is probably the best you can do:

TL/DR:

Reporting tables cannot have variable numbers or columns, nor variable column names. You can fake it to a certain extent by hiding columns and using other variables for the column names in the table header. Consider using a script data source to transform any given dataset to have the needed column names while populating the variables for the column headers from that given dataset. And hiding the unused columns.

Good luck.

I’ve created a report with a dynamic number of columns using a .csv layout. The report script uses system.tag.queryTagHistory and the list of tags to report is a parameter passed to the report and therefore of unknown size.
The results dataset goes through system.dataset.toCSV to get a csv string. Then an extra

csv = csv[1:-2]

to remove the leading/trailing " marks.
The report table is a single column that holds the resulting dataset.

The preview looks ugly and I doubt it works as a vision component, but sending by email as a file attachment works just fine.