Hello,
I would like to make an array of tables.
I have Column Selector with 2 Datasets called FirstTable and SecondTable in it. I would like to add them to one array to pass to the funciton that exports data to Excel.
How many and which Dataset i am exporting to Excel depends on CheckBoxes.
Scripting code on Button Event:
I get such error on line “tablesArray.append[table.FirstTable]” with text:
Traceback (innermost last):
File "<event:mouseReleased>", line 6, in ?
AttributeError: __getitem__
Could you please help how to add to array in a right way?
You don’t need to worry about arrays. The exportExcel function takes a dataset. Do the following:[code]CheckBox1 = event.source.parent.getComponent(‘CheckBox1’)
CheckBox2 = event.source.parent.getComponent(‘CheckBox2’)
table = event.source.parent.getComponent(‘Column Selector’)
if CheckBox1.selected == 1:
ds = table.FirstTable
if CheckBox2.selected == 1:
ds = table.SecondTable
system.dataset.exportExcel(“Report.xls”, 1, ds)[/code]That is assuming FirstTable and SecondTable are both datasets.
Thank you for your answer.
That’s right, these are Datasets.
But if i want to export more than one dataset to excel in one file, not in separated files, i need to use array?
Actually i have more than 2 datasets, these were just for example.
So if i want to add Table1 and Table3 without Table2, i need to add to tables array?
If i have 5 datasets, i have 25 possibilities of exporting them to one excel file, this is little bit complicated.
I succeeded in adding datasets to an array by my choise and exporting them to one excel file.
I had syntax error here ( dataSets.append[color=#FF0000][[/color]table.Table1[color=#FF0000]][/color] had to use these: () instead of these: [], now it is working good.
code is:
[code]table = event.source.parent.getComponent(‘Graph Column Selector’)
dataSets = []
if CheckBox1.selected == 1:
dataSets.append(table.Table1)
if CheckBox2.selected == 1:
dataSets.append(table.Table2)
if CheckBox3.selected == 1:
dataSets.append(table.Table3)
if CheckBox4.selected == 1:
dataSets.append(table.Table4)
if CheckBox5.selected == 1:
dataSets.append(table.Table5)