Perspective table help exporting to excel

component= event.source.parent.getChild("StopsData").getChild("Table")
csv = system.dataset.toCSV(component.props.data)
system.file.saveFile("myExport.csv", "csv", "Comma Separated Values")
if filePath:
  system.file.writeFile(filePath, csv)

system.file.saveFile is not available in a Perspective session.

Use system.perspective.download: system.perspective.download - Ignition User Manual 8.1 - Ignition Documentation

So your new script would look like this:

component= event.source.parent.getChild("StopsData").getChild("Table")
csv = system.dataset.toCSV(component.props.data)
system.perspective.download("myExport.csv",csv)

To change the color of a cell specifically you need to add a transform on the data so that on the column that you want to change the cell color on is a dict object with a value and a style: Color perspective table cell depending on value in another column - #2 by ynejati
or
Cell Color in Perspective Table

Doing this will probably impact your first question though.

What I do for almost 100% of all tables is have a custom property on the view that is a dataset/json that holds the data that I want. Then on the table I do a transform. That way if I need to export the data out I have an un-spoiled copy of the data that I can do something with.

4 Likes