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

**URL:** <https://forum.inductiveautomation.com/t/how-to-create-a-chart-in-excel-when-exporting-a-csv-file/95183>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [August 27, 2024, 4:26am UTC](https://forum.inductiveautomation.com/t/how-to-create-a-chart-in-excel-when-exporting-a-csv-file/95183 "2024-08-27T04:26:05Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thanin\_Pitakpoolsin](https://avatars.discourse-cdn.com/v4/letter/t/a183cd/32.png) [@Thanin\_Pitakpoolsin](https://forum.inductiveautomation.com/u/Thanin_Pitakpoolsin)\
**Post date:** [August 27, 2024, 4:26am UTC](https://forum.inductiveautomation.com/t/how-to-create-a-chart-in-excel-when-exporting-a-csv-file/95183/1 "2024-08-27T04:26:06Z")

</div>

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

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/9/b970c04119e8d73515a7ba893594227e1a01ded0.png)

and here My export CSV Code

```python
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)

```

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [August 27, 2024, 8:04am UTC](https://forum.inductiveautomation.com/t/how-to-create-a-chart-in-excel-when-exporting-a-csv-file/95183/2 "2024-08-27T08:04:02Z")

</div>

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

[Comma-separated values - Wikipedia](https://en.wikipedia.org/wiki/Comma-separated_values#:~:text=Comma%2Dseparated%20values%20(CSV),typically%20represents%20one%20data%20record).

---

<div class="post-metadata">

**Author:** ![Thanin\_Pitakpoolsin](https://avatars.discourse-cdn.com/v4/letter/t/a183cd/32.png) [@Thanin\_Pitakpoolsin](https://forum.inductiveautomation.com/u/Thanin_Pitakpoolsin)\
**Post date:** [August 27, 2024, 8:26am UTC](https://forum.inductiveautomation.com/t/how-to-create-a-chart-in-excel-when-exporting-a-csv-file/95183/3 "2024-08-27T08:26:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Hugh](https://avatars.discourse-cdn.com/v4/letter/h/c5a1d2/32.png) [@Hugh](https://forum.inductiveautomation.com/u/Hugh)\
**Post date:** [August 27, 2024, 11:33am UTC](https://forum.inductiveautomation.com/t/how-to-create-a-chart-in-excel-when-exporting-a-csv-file/95183/5 "2024-08-27T11:33:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [August 27, 2024, 11:38am UTC](https://forum.inductiveautomation.com/t/how-to-create-a-chart-in-excel-when-exporting-a-csv-file/95183/6 "2024-08-27T11:38:36Z")

</div>

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:

> [@Writing data to a excel template](https://forum.inductiveautomation.com/t/writing-data-to-a-excel-template/92674/2):
>
> There are numerous examples on this forum showing how to perform custom operations with Excel files via the Apache POI libraries that are provided with Ignition: [https://forum.inductiveautomation.com/search?q=apache%20poi%20excel%20perspective%20order%3Alatest](https://forum.inductiveautomation.com/search?q=apache%20poi%20excel%20perspective%20order%3Alatest) Most of these topics perform one the two following general sequences: Read: Upload a workbook (Perspective) or read a local workbook file (Vision), then Extract desired information from the content of the workbook, and finally Save t…

---

<div class="post-metadata">

**Author:** ![DNice](https://avatars.discourse-cdn.com/v4/letter/d/858c86/32.png) [@DNice](https://forum.inductiveautomation.com/u/DNice)\
**Post date:** [August 27, 2024, 11:52am UTC](https://forum.inductiveautomation.com/t/how-to-create-a-chart-in-excel-when-exporting-a-csv-file/95183/7 "2024-08-27T11:52:12Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [August 27, 2024, 8:53pm UTC](https://forum.inductiveautomation.com/t/how-to-create-a-chart-in-excel-when-exporting-a-csv-file/95183/8 "2024-08-27T20:53:23Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Thanin\_Pitakpoolsin](https://avatars.discourse-cdn.com/v4/letter/t/a183cd/32.png) [@Thanin\_Pitakpoolsin](https://forum.inductiveautomation.com/u/Thanin_Pitakpoolsin)\
**Post date:** [August 28, 2024, 2:42am UTC](https://forum.inductiveautomation.com/t/how-to-create-a-chart-in-excel-when-exporting-a-csv-file/95183/9 "2024-08-28T02:42:10Z")

</div>

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.
