# Tag History Export to Excel

**URL:** <https://forum.inductiveautomation.com/t/tag-history-export-to-excel/7733>\
**Category:** Ignition\
**Created:** [December 19, 2013, 5:29pm UTC](https://forum.inductiveautomation.com/t/tag-history-export-to-excel/7733 "2013-12-19T17:29:21Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![allenr8](https://avatars.discourse-cdn.com/v4/letter/a/e56c9b/32.png) [@allenr8](https://forum.inductiveautomation.com/u/allenr8)\
**Post date:** [December 19, 2013, 5:29pm UTC](https://forum.inductiveautomation.com/t/tag-history-export-to-excel/7733/1 "2013-12-19T17:29:21Z")

</div>

I have built a dynamic table that allows users to select multiple tags and an interval then export them to excel. This issue I am running into is labeling the headers so that they actually reflect the tag names.

I can dynamically change the tag, but the header stays at whatever I have left it at. By using the column properties dataset I can change the label so it looks good inside the client, but as soon as you export is uses the column name, which I cannot seem to change using the tag history tool in the binding.

for example - my Column name is actually Tag 1, but the label is Effluent Flow. When I export to excel I get Tag 1. If I change the name in the column properties, it just breaks the link with the dataset and does nothing.

Is there a way to do what I am looking for?

---

<div class="post-metadata">

**Author:** ![nmudge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nmudge/32/3394_2.png) [@nmudge](https://forum.inductiveautomation.com/u/nmudge)\
**Post date:** [December 19, 2013, 5:50pm UTC](https://forum.inductiveautomation.com/t/tag-history-export-to-excel/7733/2 "2013-12-19T17:50:30Z")

</div>

One way to do it is by creating a new dataset with the column names that you want.

Loop through your existing dataset to create a list of lists, which holds the rows of data for your dataset. Then create a list of the header names that you want.

Then call this function to create the new dataset with the column names that you want:  
dataset = system.dataset.toDataSet(headers, data)

---

<div class="post-metadata">

**Author:** ![allenr8](https://avatars.discourse-cdn.com/v4/letter/a/e56c9b/32.png) [@allenr8](https://forum.inductiveautomation.com/u/allenr8)\
**Post date:** [December 19, 2013, 6:00pm UTC](https://forum.inductiveautomation.com/t/tag-history-export-to-excel/7733/3 "2013-12-19T18:00:39Z")

</div>

I guess I will need to get familiar with the python list syntax now - where would you put this expression code exactly? On the table object?

---

<div class="post-metadata">

**Author:** ![nmudge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nmudge/32/3394_2.png) [@nmudge](https://forum.inductiveautomation.com/u/nmudge)\
**Post date:** [December 19, 2013, 7:19pm UTC](https://forum.inductiveautomation.com/t/tag-history-export-to-excel/7733/4 "2013-12-19T19:19:46Z")

</div>

I found a simpler way to change the column names of a dataset.

This code goes in the actionPerformed event handler on the button the user presses to export to excel:`
dataset = event.source.parent.getComponent('Table').data
dataset.setColumnNames(["col1","col2","col3"])
system.dataset.exportExcel("excelfile", 1,dataset)
`  
EDIT: I looked into this further and it is not good practice in Ignition to directly change existing datasets.

Instead it is better to make a copy first, for example:

```auto
from com.inductiveautomation.ignition.common import BasicDataset
dataset = BasicDataset(event.source.parent.getComponent('Table').data)
dataset.setColumnNames(["col1","col2","col3"])
system.dataset.exportExcel("excelfile", 1,dataset)
```

---

<div class="post-metadata">

**Author:** ![allenr8](https://avatars.discourse-cdn.com/v4/letter/a/e56c9b/32.png) [@allenr8](https://forum.inductiveautomation.com/u/allenr8)\
**Post date:** [December 19, 2013, 8:04pm UTC](https://forum.inductiveautomation.com/t/tag-history-export-to-excel/7733/5 "2013-12-19T20:04:30Z")

</div>

Thanks for the help - this won’t be as much brain damage.

---

<div class="post-metadata">

**Author:** ![nmudge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nmudge/32/3394_2.png) [@nmudge](https://forum.inductiveautomation.com/u/nmudge)\
**Post date:** [December 19, 2013, 9:06pm UTC](https://forum.inductiveautomation.com/t/tag-history-export-to-excel/7733/6 "2013-12-19T21:06:06Z")

</div>

Your welcome. Good to mitigate brain damage.
