# Array of Dataset tables

**URL:** <https://forum.inductiveautomation.com/t/array-of-dataset-tables/4013>\
**Category:** Ignition\
**Created:** [February 16, 2012, 3:18pm UTC](https://forum.inductiveautomation.com/t/array-of-dataset-tables/4013 "2012-02-16T15:18:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![quper](https://avatars.discourse-cdn.com/v4/letter/q/aeb1de/32.png) [@quper](https://forum.inductiveautomation.com/u/quper)\
**Post date:** [February 16, 2012, 3:18pm UTC](https://forum.inductiveautomation.com/t/array-of-dataset-tables/4013/1 "2012-02-16T15:18:25Z")

</div>

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:

[code]CheckBox1 = event.source.parent.getComponent(‘CheckBox1’)  
CheckBox2 = event.source.parent.getComponent(‘CheckBox2’)  
table = event.source.parent.getComponent(‘Column Selector’)  
tablesArray = []  
if CheckBox1.selected == 1:  
tablesArray.append[table.FirstTable]  
if CheckBox2.selected == 1:  
tablesArray.append[table.SecondTable]

fpmi.dataset.exportExcel(“Raport.xls”, 1, tablesArray)[/code]

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?

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [February 16, 2012, 4:21pm UTC](https://forum.inductiveautomation.com/t/array-of-dataset-tables/4013/2 "2012-02-16T16:21:40Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![quper](https://avatars.discourse-cdn.com/v4/letter/q/aeb1de/32.png) [@quper](https://forum.inductiveautomation.com/u/quper)\
**Post date:** [February 17, 2012, 7:52am UTC](https://forum.inductiveautomation.com/t/array-of-dataset-tables/4013/3 "2012-02-17T07:52:40Z")

</div>

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?

```auto
system.dataset.exportExcel("Report.xls", 1, [table.FirstTabe, tableSecondTable, ..., table.LastTable])
```

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.

---

<div class="post-metadata">

**Author:** ![quper](https://avatars.discourse-cdn.com/v4/letter/q/aeb1de/32.png) [@quper](https://forum.inductiveautomation.com/u/quper)\
**Post date:** [February 17, 2012, 8:46am UTC](https://forum.inductiveautomation.com/t/array-of-dataset-tables/4013/4 "2012-02-17T08:46:30Z")

</div>

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)

fpmi.dataset.exportExcel(“Raport.xls”, 1, dataSets)[/code]

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [February 17, 2012, 3:51pm UTC](https://forum.inductiveautomation.com/t/array-of-dataset-tables/4013/5 "2012-02-17T15:51:35Z")

</div>

Great to hear it is working.
