Perspective Power Chart - Excel export column headers

I’m trying to export the power chart values to excel using the default export option but the export file doesn’t show the pen names as column headers, instead shows the historical tag providers.

Is there a way to change this?

I’d like to do the exact same thing; did you ever find a way to do it?

Yeah, I added my own Export button and got rid of the in-built option. Only addition would be the custom parameters that I used from Tom Leijen’s export utility from Ignition Exchange in case I wanted to change the design in future.

import json

datetime = system.date.now()
tagPaths = []
aggregateModes = []
histPaths = []

array = self.parent.parent.getChild("PC").props.pens
names = ['Date']
for row in array:
	rowObj = row['data']
	rowName = row['name']
	names.append(rowName)
	if rowObj['aggregateMode'] == "default":
		aggregateModes.append(self.view.custom.DefaultAggregationMode)
	else:
		aggregateModes.append(rowObj['aggregateMode'])
	histPaths.append(rowObj['source'])
for histPath in histPaths:
	tagPaths.append("[default]" + str(histPath).split("tag:")[1])
endTime = self.parent.parent.getChild("PC").props.config.rangeEndDate
startTime = self.parent.parent.getChild("PC").props.config.rangeStartDate
points = self.view.custom.Points

data = system.tag.queryTagHistory(paths=tagPaths,startDate=startTime, endDate=endTime, returnSize=points, returnFormat='Wide', aggregationModes = aggregateModes)
values = []
for row in range(data.rowCount):
	valuerow = []
	for col in range(data.columnCount):
		if col == 0:
			date = str(data.getValueAt(row,col)).split('.')[0]
			valuerow.append(date)
		else:
			valuerow.append(data.getValueAt(row,col))
	values.append(valuerow)

ds = system.dataset.toDataSet(names,values)
csv = system.dataset.toCSV(ds)
filePath = system.perspective.download('Chart Export ' + str(datetime).split('.')[0] + '.csv', csv, "Comma Separated Values")

image

For points -

toInt(abs(dateDiff({view.custom.startDate}, {view.custom.endDate}, "minute"))/{value},0)
3 Likes