# How can I save Excel file to local certain folder

**URL:** <https://forum.inductiveautomation.com/t/how-can-i-save-excel-file-to-local-certain-folder/87311>\
**Category:** Ignition\
**Tags:** perspective, ignition81, scripting\
**Created:** [March 14, 2024, 4:00am UTC](https://forum.inductiveautomation.com/t/how-can-i-save-excel-file-to-local-certain-folder/87311 "2024-03-14T04:00:21Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![celo\_Tu](https://avatars.discourse-cdn.com/v4/letter/c/e9bcb4/32.png) [@celo\_Tu](https://forum.inductiveautomation.com/u/celo_Tu)\
**Post date:** [March 14, 2024, 4:00am UTC](https://forum.inductiveautomation.com/t/how-can-i-save-excel-file-to-local-certain-folder/87311/1 "2024-03-14T04:00:21Z")

</div>

```auto
def runAction(self, event):
	data = self.getSibling("Table").props.data
	#data = self.parent.parent.parent.parent.getChild("tab recipe").custom.raw
	current_date = system.date.now()
	# Get the date of the previous month
	previous_month_date = system.date.addMonths(current_date, -1)
	time = system.date.format(previous_month_date, 'yyyy_MMMM')
	filename = 'Alarm_Journal_Historical_' + time + '.xlsx'
	
	spreadsheet = system.dataset.toExcel(True, [data], True)
	system.perspective.download(filename, spreadsheet)
	system.perspective.closePopup("")

```

For this script the export Excel will download in the default Download folder.  
How can I change the path to another local computer folder, like : (Desktop/New folder)

---

<div class="post-metadata">

**Author:** ![amy.sudibyo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amy.sudibyo/32/38659_2.png) [@amy.sudibyo](https://forum.inductiveautomation.com/u/amy.sudibyo)\
**Post date:** [March 14, 2024, 4:54am UTC](https://forum.inductiveautomation.com/t/how-can-i-save-excel-file-to-local-certain-folder/87311/2 "2024-03-14T04:54:33Z")

</div>

It's not clear what you're asking. Is this script not working the way you expect it to?

You say 'CSV' but you are calling `system.dataset.toExcel` and specifying .xlsx as the extension. At the risk of sounding painfully obvious, if you want an actual CSV then you'll need `system.dataset.toCSV`.

---

<div class="post-metadata">

**Author:** ![celo\_Tu](https://avatars.discourse-cdn.com/v4/letter/c/e9bcb4/32.png) [@celo\_Tu](https://forum.inductiveautomation.com/u/celo_Tu)\
**Post date:** [March 14, 2024, 5:18am UTC](https://forum.inductiveautomation.com/t/how-can-i-save-excel-file-to-local-certain-folder/87311/3 "2024-03-14T05:18:21Z")

</div>

Sorry ,I revise my title.  
I want to ask how can I export the file to certain path  
(ex: C:\Users\Desktop\Alarmlog )

---

<div class="post-metadata">

**Author:** ![amy.sudibyo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amy.sudibyo/32/38659_2.png) [@amy.sudibyo](https://forum.inductiveautomation.com/u/amy.sudibyo)\
**Post date:** [March 14, 2024, 5:43am UTC](https://forum.inductiveautomation.com/t/how-can-i-save-excel-file-to-local-certain-folder/87311/4 "2024-03-14T05:43:09Z")

</div>

Do you want the file to be downloaded to a specific hardcoded directory, or somewhere that is selected by the user?

`system.perspective.download` can open a prompt for the user to select download location, provided your browser is set up that way.

> [@system.perspective.download()](https://forum.inductiveautomation.com/t/system-perspective-download/46388/2):
>
> What happens when you download a file is up to your environment + browser; it’s literally outside of Ignition’s control. What platform(s) are you launching sessions on?

---

<div class="post-metadata">

**Author:** ![celo\_Tu](https://avatars.discourse-cdn.com/v4/letter/c/e9bcb4/32.png) [@celo\_Tu](https://forum.inductiveautomation.com/u/celo_Tu)\
**Post date:** [March 14, 2024, 5:56am UTC](https://forum.inductiveautomation.com/t/how-can-i-save-excel-file-to-local-certain-folder/87311/5 "2024-03-14T05:56:37Z")

</div>

I look forward to have a save option like this picture  
 ![savepic](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/3/e32fa7da8d0b0f88bb73a5b4e7809e80e2ebfec2.png)  
I can choose the specific path to save my file  
I'm not sure how I can use the system.file.writeFile(file\_path, spreadsheet) to do it  
Or anything else method to do

---

<div class="post-metadata">

**Author:** ![amy.sudibyo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amy.sudibyo/32/38659_2.png) [@amy.sudibyo](https://forum.inductiveautomation.com/u/amy.sudibyo)\
**Post date:** [March 14, 2024, 6:10am UTC](https://forum.inductiveautomation.com/t/how-can-i-save-excel-file-to-local-certain-folder/87311/6 "2024-03-14T06:10:38Z")

</div>

Did you read my last post and/or link?

---

<div class="post-metadata">

**Author:** ![celo\_Tu](https://avatars.discourse-cdn.com/v4/letter/c/e9bcb4/32.png) [@celo\_Tu](https://forum.inductiveautomation.com/u/celo_Tu)\
**Post date:** [March 14, 2024, 6:19am UTC](https://forum.inductiveautomation.com/t/how-can-i-save-excel-file-to-local-certain-folder/87311/7 "2024-03-14T06:19:49Z")

</div>

Yes, I read it and it can work by setting the download location on the browser.  
But I have too much file for download ,it will cause a little mess in folder.  
So I want to find the method how to save different file to different folder

---

<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:** [March 14, 2024, 9:42am UTC](https://forum.inductiveautomation.com/t/how-can-i-save-excel-file-to-local-certain-folder/87311/8 "2024-03-14T09:42:34Z")

</div>

For security reasons the browser can save files in one of two ways:

1. When the download link is clicked save in a location specified by the browser setup options.
2. Open the save dialog (as specified in the browser setup options) as shown in your screen grab.

A website can't specify that a file be saved in, for example, C:\Users\Desktop\Alarmlog. For a start that's Windows-only syntax and the folders might not exist.

---

<div class="post-metadata">

**Author:** ![celo\_Tu](https://avatars.discourse-cdn.com/v4/letter/c/e9bcb4/32.png) [@celo\_Tu](https://forum.inductiveautomation.com/u/celo_Tu)\
**Post date:** [March 14, 2024, 10:07am UTC](https://forum.inductiveautomation.com/t/how-can-i-save-excel-file-to-local-certain-folder/87311/9 "2024-03-14T10:07:34Z")

</div>

So I can't create a folder and set the certain path in my script to save my file right?  
The only way to download is setting the browser download option like this?

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

---

<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:** [March 14, 2024, 10:22am UTC](https://forum.inductiveautomation.com/t/how-can-i-save-excel-file-to-local-certain-folder/87311/10 "2024-03-14T10:22:54Z")

</div>

Correct. It's controlled by the browser, and not by Ignition.

---

<div class="post-metadata">

**Author:** ![celo\_Tu](https://avatars.discourse-cdn.com/v4/letter/c/e9bcb4/32.png) [@celo\_Tu](https://forum.inductiveautomation.com/u/celo_Tu)\
**Post date:** [March 14, 2024, 10:29am UTC](https://forum.inductiveautomation.com/t/how-can-i-save-excel-file-to-local-certain-folder/87311/11 "2024-03-14T10:29:31Z")

</div>

Thank you for helping

---

<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:** [March 14, 2024, 11:07am UTC](https://forum.inductiveautomation.com/t/how-can-i-save-excel-file-to-local-certain-folder/87311/12 "2024-03-14T11:07:10Z")

</div>

Just so you understand **why** : You are asking for behavior that can easily be exploited by malware. It is simply **not safe** for browsers to allow websites to specify a target folder.
