How to create a chart in Excel when exporting a CSV file

Hello, I want to create a chart in Excel like this.

and here My export CSV Code

from com.inductiveautomation.ignition.common import BasicDataset
	 
	 newColumns = ['Date','MDB2(KW-H/Day)','Cold Water Pump(KW-H/Day)','Waste Water Treatment(KW-H/Day)','Software Pump(KW-H/Day)','Water Treatment(KW-H/Day)'
	 	,'Lighting Receptacial Water Tank(KW-H/Day)','Softener(KW-H/Day)','Lighting Receptacial Solid West(KW-H/Day)','WWTP Plant4(KW-H/Day)']
	 data = self.getSibling("Table").props.data
	 dataset = BasicDataset(newColumns, data.columnTypes, data)
	 formattedData = system.dataset.formatDates(dataset, "dd-MM-yyyy HH:mm:ss")
	 today = system.date.now()
	 fileSuffix = system.date.format(today, "ddMMyyyyHHmm")
	 csvData = system.dataset.toExcel(1,[formattedData], sheetNames = ['MDB2'])
	 filename = 'Report_MDB2_' + str(fileSuffix) + '.csv'
	 system.perspective.download(filename, csvData)

CSV is a plain text file format. You can't include graphics or formatting.

Comma-separated values - Wikipedia.

1 Like

Would you have any ideas on how to accomplish it? Thank you very much.

Try system.dataset.exportExcel().
I’m not sure that will let you add colours though

Consider creating an Excel file that has space for data, plus a chart pre-defined to use that space for its data. Store that "Excel template" in some gateway-readable folder in your server. Then use the approach described here to fill in the data and deliver the file:

A suggestion - there are lots of great tools that can display this data super well without having to worry about all the excel formatting and troubleshooting. PowerBI, Graphana, Ignition, etc... I have found it much easier to share a link to something I know will work rather than a csv/excel. You may even find that making something once in one of the mentioned tools will take you the same or less time than doing it the excel route. Plus, the mentioned tools allow csv export if anyone whats to do further analysis.

Do you have a licence for the Reporting module?
Vision, Perspective and Reporting can generate those sort of pages or reports on the fly. Why do you want an Excel file?

Yes, I have the license, but users need the data in Excel format, including raw data and charts, for more flexible analysis and easier usage. The issue with the Reporting module is that the chart appears on every page.