# Webdev and Excel or CSV download

**URL:** <https://forum.inductiveautomation.com/t/webdev-and-excel-or-csv-download/32646>\
**Category:** Ignition\
**Tags:** ignition80\
**Created:** [February 27, 2020, 12:15am UTC](https://forum.inductiveautomation.com/t/webdev-and-excel-or-csv-download/32646 "2020-02-27T00:15:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![David.Reed.Schmidt](https://avatars.discourse-cdn.com/v4/letter/d/5f9b8f/32.png) [@David.Reed.Schmidt](https://forum.inductiveautomation.com/u/David.Reed.Schmidt)\
**Post date:** [February 27, 2020, 12:15am UTC](https://forum.inductiveautomation.com/t/webdev-and-excel-or-csv-download/32646/1 "2020-02-27T00:15:46Z")

</div>

How can I use the webdev module to export an excel or csv to the perspective client?

Its a common scenario. I have a perspective client with a button on it. There is a DB back end to the Ignition server. The customer wants to click a button and download an excel or csv file.

Does anybody have any examples?

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [February 27, 2020, 12:31am UTC](https://forum.inductiveautomation.com/t/webdev-and-excel-or-csv-download/32646/2 "2020-02-27T00:31:29Z")

</div>

Do you even need the WebDev module for this?

Can you just use this? [https://docs.inductiveautomation.com/display/DOC80/system.perspective.download](https://docs.inductiveautomation.com/display/DOC80/system.perspective.download)

---

<div class="post-metadata">

**Author:** ![David.Reed.Schmidt](https://avatars.discourse-cdn.com/v4/letter/d/5f9b8f/32.png) [@David.Reed.Schmidt](https://forum.inductiveautomation.com/u/David.Reed.Schmidt)\
**Post date:** [February 27, 2020, 12:33am UTC](https://forum.inductiveautomation.com/t/webdev-and-excel-or-csv-download/32646/3 "2020-02-27T00:33:55Z")

</div>

As I understand. the system.perspective.download will download the file to the Ignition server and not the actual perspective client.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [February 27, 2020, 12:39am UTC](https://forum.inductiveautomation.com/t/webdev-and-excel-or-csv-download/32646/4 "2020-02-27T00:39:05Z")

</div>

Give a try, your browser will prompt you to download a file.

---

<div class="post-metadata">

**Author:** ![David.Reed.Schmidt](https://avatars.discourse-cdn.com/v4/letter/d/5f9b8f/32.png) [@David.Reed.Schmidt](https://forum.inductiveautomation.com/u/David.Reed.Schmidt)\
**Post date:** [February 29, 2020, 12:12am UTC](https://forum.inductiveautomation.com/t/webdev-and-excel-or-csv-download/32646/5 "2020-02-29T00:12:05Z")

</div>

For what its worth this is what I did to extract the data from the database and return it as a csv file from the perspective client.

First, from a button I do a navigation to the following url

`gatewayAddress:port/system/webdev/project/data/data?StartDate=2020-02-01 00:00:00&EndDate=2020-02-01 00:00:00`

Using the webdev module:

```
#/system/webdev/IRCTS/Data/Data
L = system.util.getLogger("Webdev: Data/Data")
L.info("start")
startDate = request['params']['StartDate']
endDate = request['params']['EndDate']
params = {"startTime":startDate, "endTime":endDate}
dataSet = system.db.runNamedQuery('Project', 'ReportPath', params)
csv = system.dataset.toCSV(dataSet)
filePath = r"C:\Users\Public\Documents\Ignition\data.csv"
system.file.writeFile(filePath, csv)
bytes = system.file.readFileAsBytes(filePath)
L.info("end")
return {'bytes': bytes}

```

Once I press the button in the perspective client the browser ask where I want to download the csv file.
