# \[Feature-13610\]Export to Excel in Perspective Ignition 8

**URL:** <https://forum.inductiveautomation.com/t/feature-13610-export-to-excel-in-perspective-ignition-8/24177>\
**Category:** Ignition Early Access\
**Tags:** ignition80, scripting\
**Created:** [April 16, 2019, 3:23pm UTC](https://forum.inductiveautomation.com/t/feature-13610-export-to-excel-in-perspective-ignition-8/24177 "2019-04-16T15:23:56Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![ceszamora](https://avatars.discourse-cdn.com/v4/letter/c/54ee81/32.png) [@ceszamora](https://forum.inductiveautomation.com/u/ceszamora)\
**Post date:** [April 16, 2019, 3:23pm UTC](https://forum.inductiveautomation.com/t/feature-13610-export-to-excel-in-perspective-ignition-8/24177/1 "2019-04-16T15:23:56Z")

</div>

hello,

If I have a Table in on a View, Could I export all data to an EXCEL file? Could I use system.dataset.exportExcel?

thank you all

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [April 16, 2019, 3:37pm UTC](https://forum.inductiveautomation.com/t/feature-13610-export-to-excel-in-perspective-ignition-8/24177/2 "2019-04-16T15:37:24Z")

</div>

Unfortunately, no, you may not. `system.dataset.exportExcel()` is scoped for the Vision Client. For any exporting, Vision is your only option at this time.

You are able to write to files (create a new file) from Perspective, but the file will be placed on the Gateway machine - not your local environment (unless they happen to be the same).

---

<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:** [April 16, 2019, 5:37pm UTC](https://forum.inductiveautomation.com/t/feature-13610-export-to-excel-in-perspective-ignition-8/24177/3 "2019-04-16T17:37:59Z")

</div>

The WebDev module would be an option for this, implementing a download link for a dynamically generated file of any type.

---

<div class="post-metadata">

**Author:** ![alan\_pereira](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alan_pereira/32/79668_2.png) [@alan\_pereira](https://forum.inductiveautomation.com/u/alan_pereira)\
**Post date:** [April 16, 2019, 7:54pm UTC](https://forum.inductiveautomation.com/t/feature-13610-export-to-excel-in-perspective-ignition-8/24177/4 "2019-04-16T19:54:47Z")

</div>

We are currently developing a solution using Excel in our project, so that the user is able to preview and download reports both in excel and PDF. So far it's stable and we were able to create the xlsx report that looks almost the same as the PDF.  
We are using a 3rd party python library, xlsxwriter, and the standard xml library to interpret the report content as XML ( system.report.executeReport, fileType="xml"). When the file is generated, you can read as byte array and then use system.perspective.download.

Unfortunately it's not a built-in feature, so it's fairly limited.

Here's an example:  
[BSM Report.xls](https://us1.discourse-cdn.com/inductiveautomation/original/2X/f/f368b2fc7fc5b7028e3e6be35d1e99e50f01f303.xls) (25.5 KB)

---

<div class="post-metadata">

**Author:** ![silverbacknet](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/silverbacknet/32/7385_2.png) [@silverbacknet](https://forum.inductiveautomation.com/u/silverbacknet)\
**Post date:** [April 16, 2019, 11:44pm UTC](https://forum.inductiveautomation.com/t/feature-13610-export-to-excel-in-perspective-ignition-8/24177/5 "2019-04-16T23:44:09Z")

</div>

> [@alan\_pereira](#):
>
> Unfortunately it's not a built-in feature, so it's fairly limited.

It might not be built-in, but xlsxwriter is insanely powerful, much more so than exportExcel(), and not hard to harness. I'd be interested in whatever glue code you used to get it up and running, because I think it would be a great addition to my project as well.

---

<div class="post-metadata">

**Author:** ![alan\_pereira](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alan_pereira/32/79668_2.png) [@alan\_pereira](https://forum.inductiveautomation.com/u/alan_pereira)\
**Post date:** [April 17, 2019, 2:29pm UTC](https://forum.inductiveautomation.com/t/feature-13610-export-to-excel-in-perspective-ignition-8/24177/6 "2019-04-17T14:29:02Z")

</div>

Here is a snippet:

> def datasetListFromXML(bytesArray):  
> import xml.etree.ElementTree as ET  
> root = ET.fromstring(bytesArray.tostring())  
> for g0child in root.findall('page'):  
> for g1child in g0child.findall('shape'): #table  
> for row\_n,g2child in enumerate(g1child.findall('shape')): #row  
> for colndx,g3child in enumerate(g2child.findall('text')): #column  
> ...  
> return tbl
> 
> def XMLtoXLSX(rptName, bytesArray, params):  
> import xlsxwriter
> 
> ```
> dataset_list = datasetListFromXML(bytesArray)
> 
> workbook = xlsxwriter.Workbook(fileName)
> worksheet = workbook.add_worksheet('Report')
> 
> content_format = workbook.add_format({'border': 1, 'align' : 'left'})
> 
> row = 3
> for ds in dataset_list:
> for col,val in enumerate(ds[0]):
> worksheet.write(row, col, val, content_format)
> row += 1
> 
> # Page layout 
> worksheet.set_page_view()
> worksheet.set_paper(paper_size)
> worksheet.set_landscape()
> 
> workbook.close()
> bArray = system.file.readFileAsBytes(fileName)
> return bArray
> 
> ```
> 
> def downReport():  
> bytesArray = system.report.executeReport(path=rptName, project=prjName, parameters=input, fileType=fType)  
> XLbArray = XMLtoXLSX(bytesArray)  
> system.perspective.download(rptName+'.'+fmt.lower(),XLbArray)

I hope that helps.

---

<div class="post-metadata">

**Author:** ![Steve\_Laubach](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/steve_laubach/32/60900_2.png) [@Steve\_Laubach](https://forum.inductiveautomation.com/u/Steve_Laubach)\
**Post date:** [April 17, 2019, 8:40pm UTC](https://forum.inductiveautomation.com/t/feature-13610-export-to-excel-in-perspective-ignition-8/24177/7 "2019-04-17T20:40:39Z")

</div>

Do you have a rough ETA on when exporting to excel is planned to come to Perspective?

I’m trying to gauge whether it makes sense for me to write a back end solution that writes csv files on the gateway or if I should wait for the Perspective toolset to be more fleshed out.

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [April 18, 2019, 2:13pm UTC](https://forum.inductiveautomation.com/t/feature-13610-export-to-excel-in-perspective-ignition-8/24177/8 "2019-04-18T14:13:42Z")

</div>

I’m unaware of any current plans to provide exports through Perspective, although - as @pturmel mentioned - there are alternative avenues by coupling Perspective with the WebDev Module. Alternatively, it would probably be pretty easy for us to provide a `props.download` property for the Link component which inserts a download tag for the associated anchor… I’ll put in a feature request for that as it’s a good “quick-and-dirty” option, but even the feature request will probably take quite some time to see the light of day.

TLDR; 8.0.2 at the absolute earliest, 8.0.3 is more likely.

---

<div class="post-metadata">

**Author:** ![Steve\_Laubach](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/steve_laubach/32/60900_2.png) [@Steve\_Laubach](https://forum.inductiveautomation.com/u/Steve_Laubach)\
**Post date:** [April 18, 2019, 3:05pm UTC](https://forum.inductiveautomation.com/t/feature-13610-export-to-excel-in-perspective-ignition-8/24177/9 "2019-04-18T15:05:44Z")

</div>

Thanks for your response. I have a customer asking me. They were trying to determine whether we custom write a csv export or wait for the feature to exist natively.

We’re going to custom write at least for the pilot system. They are hoping for this feature. Thanks for the rough ETA and adding the feature request.

---

<div class="post-metadata">

**Author:** ![Tumeksi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/tumeksi/32/4697_2.png) [@Tumeksi](https://forum.inductiveautomation.com/u/Tumeksi)\
**Post date:** [October 22, 2019, 12:23pm UTC](https://forum.inductiveautomation.com/t/feature-13610-export-to-excel-in-perspective-ignition-8/24177/10 "2019-10-22T12:23:17Z")

</div>

Hi,  
What is the situation on this?  
Many of our customers are asking for this functionality.

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [October 22, 2019, 2:28pm UTC](https://forum.inductiveautomation.com/t/feature-13610-export-to-excel-in-perspective-ignition-8/24177/11 "2019-10-22T14:28:46Z")

</div>

No progress has been made insofar as modifying the Link to trigger downloads, but as others have mentioned this is possible when using the Web Dev module in conjunction with Perspective.

---

<div class="post-metadata">

**Author:** ![craigb](https://avatars.discourse-cdn.com/v4/letter/c/9f8e36/32.png) [@craigb](https://forum.inductiveautomation.com/u/craigb)\
**Post date:** [October 22, 2019, 2:46pm UTC](https://forum.inductiveautomation.com/t/feature-13610-export-to-excel-in-perspective-ignition-8/24177/12 "2019-10-22T14:46:48Z")

</div>

```auto
	dataset = self.parent.parent.getChild("Table Container").getChild("Your_Table").props.data
	data = system.dataset.toCSV(dataset, 1, 0, 0)
	filename = 'Orders.csv'
	system.perspective.download(filename, data)

```

---

<div class="post-metadata">

**Author:** ![craigb](https://avatars.discourse-cdn.com/v4/letter/c/9f8e36/32.png) [@craigb](https://forum.inductiveautomation.com/u/craigb)\
**Post date:** [October 22, 2019, 2:49pm UTC](https://forum.inductiveautomation.com/t/feature-13610-export-to-excel-in-perspective-ignition-8/24177/13 "2019-10-22T14:49:24Z")

</div>

```auto
	table = self.parent.parent.getChild("Table Container").getChild("Table").props.data
	excelstr = system.dataset.dataSetToExcel(True,[table])
	excelbytes = system.dataset.dataSetToHTML(1, table, "")
	OrderNo = self.view.params.OrderID
	fileName = "Purchase Request Number %s.xls" % OrderNo
	system.perspective.download(fileName, excelbytes)

```

---

<div class="post-metadata">

**Author:** ![Phil\_B](https://avatars.discourse-cdn.com/v4/letter/p/c89c15/32.png) [@Phil\_B](https://forum.inductiveautomation.com/u/Phil_B)\
**Post date:** [November 1, 2019, 7:48pm UTC](https://forum.inductiveautomation.com/t/feature-13610-export-to-excel-in-perspective-ignition-8/24177/14 "2019-11-01T19:48:49Z")

</div>

Hello @ceszamora,

I just had this same issue come up and here is what i came up with. this is a script i put on a button.

```auto
	value = self.parent.parent.getChild("Table").props.data
	headers = value[0].keys()
	datasetData = []
	for row in range(len(value)):	
		rowData = []
		for col in range(len(headers)):
			rowData.append(value[row][headers[col]])
		datasetData.append(rowData)
	finalDataset = system.dataset.toDataSet(headers,datasetData)
	XLSFormat = system.dataset.dataSetToExcel(True,[finalDataset])
	system.perspective.download("test.xls",XLSFormat)

```

You will need change the path to your table’s data prop and also the filename. I tested it on my system but i don’t have excel installed, i just have an excel file reader and it opened with no issues.

I found that i needed to convert json to a dataset in order to make my instance work.

Let me know if you find a better way.

---

<div class="post-metadata">

**Author:** ![weixionglichina](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/weixionglichina/32/10650_2.png) [@weixionglichina](https://forum.inductiveautomation.com/u/weixionglichina)\
**Post date:** [November 4, 2019, 7:57am UTC](https://forum.inductiveautomation.com/t/feature-13610-export-to-excel-in-perspective-ignition-8/24177/15 "2019-11-04T07:57:00Z")

</div>

Just a little bit change , and I export with default table @Phil_B

> [@\[Feature-13610\]Export to Excel in Perspective Ignition 8](http://forum.inductiveautomation.com/t/feature-13610-export-to-excel-in-perspective-ignition-8/24177/14):
>
> Hello @ceszamora, I just had this same issue come up and here is what i came up with. this is a script i put on a button. value = self.parent.parent.getChild("Table").props.data headers = value[0].keys() datasetData = [] for row in range(len(value)): rowData = [] for col in range(len(headers)): rowData.append(value[row][headers[col]]) datasetData.append(rowData) finalDataset = system.dataset.toDataSet(headers,datasetData) XLSFormat = system.dataset.dataSetToExcel(True,[finalDat…

```
data = self.parent.getChild("Table").props.data
headers = data[0].keys()
system.perspective.print(headers)

datasetData = []
for row in range(len(data)):	
	rowData = []
	for col in range(len(headers)):
		cell = data[row][headers[col]]
		if hasattr(cell, 'value'):
			rowData.append(cell.value)
		else:
			rowData.append(cell)
	#system.perspective.print(rowData)
	datasetData.append(rowData)

#system.perspective.print(datasetData)	
finalDataset = system.dataset.toDataSet(headers,datasetData)
XLSFormat = system.dataset.dataSetToExcel(True,[finalDataset])
system.perspective.download("test.xls",XLSFormat)

```

---

<div class="post-metadata">

**Author:** ![djones](https://avatars.discourse-cdn.com/v4/letter/d/43a26b/32.png) [@djones](https://forum.inductiveautomation.com/u/djones)\
**Post date:** [July 15, 2020, 5:43pm UTC](https://forum.inductiveautomation.com/t/feature-13610-export-to-excel-in-perspective-ignition-8/24177/16 "2020-07-15T17:43:17Z")

</div>

This worked great!

---

<div class="post-metadata">

**Author:** ![johnmichael.savio](https://avatars.discourse-cdn.com/v4/letter/j/7ba0ec/32.png) [@johnmichael.savio](https://forum.inductiveautomation.com/u/johnmichael.savio)\
**Post date:** [August 24, 2020, 11:27am UTC](https://forum.inductiveautomation.com/t/feature-13610-export-to-excel-in-perspective-ignition-8/24177/17 "2020-08-24T11:27:28Z")

</div>

Hi,

Has there been any development regarding exporting data from perspective in the current versions (8.0.15)

Thanks,  
John

---

<div class="post-metadata">

**Author:** ![ali](https://avatars.discourse-cdn.com/v4/letter/a/8c91f0/32.png) [@ali](https://forum.inductiveautomation.com/u/ali)\
**Post date:** [January 19, 2021, 3:54pm UTC](https://forum.inductiveautomation.com/t/feature-13610-export-to-excel-in-perspective-ignition-8/24177/18 "2021-01-19T15:54:22Z")

</div>

Hi all,

I got onto this forum thread looking for a way to download a table from perspective just like you all. I was able to figure it out on Ignition 8.1.0 (Perspective Module 2.1.0) by doing the following:

1. Message Handler Script on Table component (1 indent on all lines) (Message Type was ‘download-test-data’) (Listen Scopes, selected ‘View’) :  
fileName = ‘testData.xls’  
excelbytes = system.dataset.dataSetToHTML(1, self.props.data, “”)  
system.perspective.download(fileName, excelbytes)

2. On Click Event on Button component (1 indent on all lines):  
messageType = ‘download-test-data’  
system.perspective.sendMessage(messageType, scope = ‘view’)

Thanks for the discussion guys!

---

<div class="post-metadata">

**Author:** ![mcgheeiv](https://avatars.discourse-cdn.com/v4/letter/m/71c47a/32.png) [@mcgheeiv](https://forum.inductiveautomation.com/u/mcgheeiv)\
**Post date:** [February 7, 2021, 3:01pm UTC](https://forum.inductiveautomation.com/t/feature-13610-export-to-excel-in-perspective-ignition-8/24177/19 "2021-02-07T15:01:10Z")

</div>

My table has hidden columns and custom headings… I found the following works well:

```
columns = self.getSibling("Table").props.columns
header = [col.header.title for col in columns if col.visible]

data = self.getSibling("Table").props.data
data = [[data.getValueAt(i,j) for j in range(data.columnCount) if columns[j].visible] for i in range(data.rowCount)]

data = system.dataset.toDataSet(header, data)
data = system.dataset.toExcel(True, [data])

system.perspective.download('test.xls',data)
```

---

<div class="post-metadata">

**Author:** ![jd1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jd1/32/18928_2.png) [@jd1](https://forum.inductiveautomation.com/u/jd1)\
**Post date:** [March 9, 2021, 9:47pm UTC](https://forum.inductiveautomation.com/t/feature-13610-export-to-excel-in-perspective-ignition-8/24177/20 "2021-03-09T21:47:59Z")

</div>

I am using this script as it was posted here, but I get the following error I try and open it in excel. " The file format and extension of ‘test.xls’ don’t match. The file could be corrupted or unsafe. Unless you trust its source, don’t open it. DO you want to open it anyway?" If I click yes the file will open. I should also add the save dialog box that opens when the script runs doesn’t list a file type and so I am adding the “.xls” to the end of the file name. Any ideas on what might be causing this issue?

[Next page](https://forum.inductiveautomation.com/t/feature-13610-export-to-excel-in-perspective-ignition-8/24177.md?page=2)
