# Easy Chart exportExcel rename headers?

**URL:** <https://forum.inductiveautomation.com/t/easy-chart-exportexcel-rename-headers/83223>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [December 16, 2023, 8:46am UTC](https://forum.inductiveautomation.com/t/easy-chart-exportexcel-rename-headers/83223 "2023-12-16T08:46:36Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [December 16, 2023, 1:16pm UTC](https://forum.inductiveautomation.com/t/easy-chart-exportexcel-rename-headers/83223/4 "2023-12-16T13:16:24Z")

</div>

> [@taohongyu88](#):
>
> `easyChart.exportExcel('myFileName.xls')`

[One approach that I've used for this](https://forum.inductiveautomation.com/t/easy-chart-vision/72209/8) involves getting the data from the chart indirectly, and then, changing the header names before using `system.dataset.exportExcel`/`CSV` to save the file. Here is an example that has been adapted for this use case:

```auto
# Get the easyChart component
easyChart = event.source.parent.getComponent('ChartContainer').getComponent('Easy Chart')

# This function extracts the row data from the supplied dataset.
# ...Then, it creates a new dataset using the provided headers
def renameHeaders(dataset, headers):
	values = [[dataset.getValueAt(row,col) for col in range(dataset.columnCount)] for row in range(dataset.rowCount)]
	return system.dataset.toDataSet(headers,values)

# Get the tag paths column as a java list
tagPaths = list(easyChart.tagPens.getColumnAsList(easyChart.tagPens.getColumnIndex('TAG_PATH')))

# Create a list with the desired header names
headers = ['Time Stamp', 'jobpress']

# Get the displayed start date and end date from the chart
startTime = easyChart.zoomedStartDate
endTime = easyChart.zoomedEndDate

# Get the easy chart's dataset indirectly with a tag history query using the easy chart's parameters
tagHistory = system.tag.queryTagHistory(paths=tagPaths, startDate=startTime, endDate=endTime, returnSize=-1, aggregationMode="Maximum", returnFormat='Wide', noInterpolation=True)

# Use the renameHeaders function to replace the headers that were returned by the tag history query
dataset = renameHeaders(tagHistory, headers)

# Create an xls file using the modified dataset
system.dataset.exportExcel('myFileName.xls', True, dataset)

```

**Result:**  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/d/6d04587fead96a86b88732d592d88927936adaeb.png)

**Edit:**  
@bschroeder posted his reply while I was putting mine together, so I didn't notice it. I tested the `exportDatasets` he listed and was pleased to see that it also returns only the displayed _[zoomed]_ values. Here is the above example adapted to use that method:

```auto
# Get the easyChart component
easyChart = event.source.parent.getComponent('ChartContainer').getComponent('Easy Chart')

# This function extracts the row data from the supplied dataset.
# ...Then, it creates a new dataset using the provided headers
def renameHeaders(dataset, headers):
	values = [[dataset.getValueAt(row,col) for col in range(dataset.columnCount)] for row in range(dataset.rowCount)]
	return system.dataset.toDataSet(headers,values)

# Get the tag paths column as a java list
tagPaths = list(easyChart.tagPens.getColumnAsList(easyChart.tagPens.getColumnIndex('TAG_PATH')))

# Create a list with the desired header names
headers = ['Time Stamp', 'jobpress']

# Use the renameHeaders function in conjunction with exportDatasets
# ...to produce a dataset with the desired header names
dataset = renameHeaders(easyChart.exportDatasets()[0], headers)

# Create an xls file using the modified dataset
system.dataset.exportExcel('myFileName.xls', True, dataset)

```

---

_[View the full topic](https://forum.inductiveautomation.com/t/easy-chart-exportexcel-rename-headers/83223)._
