# excel export and saving / opening file

**URL:** <https://forum.servoy.com/t/excel-export-and-saving-opening-file/19053>\
**Category:** Classic Servoy\
**Created:** [November 16, 2016, 11:08am UTC](https://forum.servoy.com/t/excel-export-and-saving-opening-file/19053 "2016-11-16T11:08:37Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![derk.hulshof](https://avatars.discourse-cdn.com/v4/letter/d/e47774/32.png) [@derk.hulshof](https://forum.servoy.com/u/derk.hulshof)\
**Post date:** [November 16, 2016, 11:08am UTC](https://forum.servoy.com/t/excel-export-and-saving-opening-file/19053/1 "2016-11-16T11:08:37Z")

</div>

hi all,

I trying to get an export done.  
ng is nog fully supporting the plugins.file option. (ex filesavedialog). At least it is giving me errors.

So to save the file I am using  
var \_filename = ‘somefilename.xlsx’;  
var \_dir = ‘c:\temp’;  
var \_file = plugins.file.convertToJSFile(\_dir + ‘\’ + \_filename)

Now the problem is the file is stored on the server in the c:\temp directory.

There is an option like plugins.file.getDesktopFolder() with getAbsolutePath()  
To get user based save location. But the servoy server is complaining with an error.

IS there anyone who can tell me how to create a file save for the user instead of using a shared directory somewhere in the network.

Tnx in advance  
Derk  
Solution type NG  
Servoy 8.0.3  
Java 8. 111  
tomcat 8.0.28 on windows server

---

<div class="post-metadata">

**Author:** ![patrick](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@patrick](https://forum.servoy.com/u/patrick)\
**Post date:** [November 16, 2016, 12:05pm UTC](https://forum.servoy.com/t/excel-export-and-saving-opening-file/19053/2 "2016-11-16T12:05:12Z")

</div>

NG client runs on the server (just like the webclient), so any direct file operation is performed on the server. And this functionality can’t be translated 1 to 1 as in the smart client (which runs on the client machine), because from within a web browser you can’t simply manipulate the client’s file system (and you can be very happy about that - imagine any web page could simply read and write files on your hard drive).

Have a look at this [https://wiki.servoy.com/display/DOCS/file](https://wiki.servoy.com/display/DOCS/file). It explains the differences in file handling between smart and web client.

---

<div class="post-metadata">

**Author:** ![derk.hulshof](https://avatars.discourse-cdn.com/v4/letter/d/e47774/32.png) [@derk.hulshof](https://forum.servoy.com/u/derk.hulshof)\
**Post date:** [November 16, 2016, 12:07pm UTC](https://forum.servoy.com/t/excel-export-and-saving-opening-file/19053/3 "2016-11-16T12:07:58Z")

</div>

Tnx for the reply,

I understand the part of client and server side file handling.

But maybe there was option bypass this and trigger the filesavedialog or something on the client.

For this there is just the option of a file share somewhere in the network.

---

<div class="post-metadata">

**Author:** ![patrick](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@patrick](https://forum.servoy.com/u/patrick)\
**Post date:** [November 16, 2016, 12:10pm UTC](https://forum.servoy.com/t/excel-export-and-saving-opening-file/19053/4 "2016-11-16T12:10:46Z")

</div>

As far as I understand you create an excel file and want to download it to the client? That is possible from within the browser, but it will end up in the user’s download folder and you can’t change that.

---

<div class="post-metadata">

**Author:** ![derk.hulshof](https://avatars.discourse-cdn.com/v4/letter/d/e47774/32.png) [@derk.hulshof](https://forum.servoy.com/u/derk.hulshof)\
**Post date:** [November 16, 2016, 12:32pm UTC](https://forum.servoy.com/t/excel-export-and-saving-opening-file/19053/5 "2016-11-16T12:32:15Z")

</div>

I tried to create the file in an network share. Shouldnt that be possible? Because below the error.  
The server user has priviliges to create documents in that folder.

2016-11-16 13:28 Executor,uuid:7b7f518a-a032-446c-9b41-8672cb2c3e3a ERROR com.servoy.j2db.util.Debug \[sharefoldername]\admin\_alle-relaties\_16-11-2016\_13276.xlsx cannot be created!, script stacktrace: at bcore/scopes/dialog/showFormDialog:78 (showFormDialog) at bcore/scopes/synchronize/exportExcel:26 (exportExcel) D6394B8E-A25C-44A1-804A-63D1FBA1926B ibisng  
2016-11-16 13:28 Executor,uuid:7b7f518a-a032-446c-9b41-8672cb2c3e3a ERROR com.servoy.j2db.util.Debug \[sharefoldername]\admin\_alle-relaties\_16-11-2016\_13276.xlsx cannot be created! D6394B8E-A25C-44A1-804A-63D1FBA1926B ibisng  
org.mozilla.javascript.WrappedException: Wrapped java.lang.RuntimeException: \[sharefoldername]\admin\_alle-relaties\_16-11-2016\_13276.xlsx cannot be created! (bcore/scopes/synchronize/writeToExcelFile#253)  
at org.mozilla.javascript.Context.throwAsScriptRuntimeEx(Context.java:1815)  
at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:180)  
at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:312)  
at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1774)  
at script.writeToExcelFile(bcore/scopes/synchronize/writeToExcelFile:253)  
at script.initCreateExcel(bcore/scopes/synchronize/initCreateExcel:99)  
at script.onActionExport(bcore/forms/dlg\_select\_exportexcel/onActionExport:40)  
at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:837)  
at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:158)  
at com.servoy.j2db.scripting.ScriptEngine.executeFunction(ScriptEngine.java:667)  
at com.servoy.j2db.server.ngclient.component.EventExecutor.executeEvent(EventExecutor.java:187)  
at com.servoy.j2db.server.ngclient.DataAdapterList.executeEvent(DataAdapterList.java:106)  
at com.servoy.j2db.server.ngclient.WebFormComponent$FormcomponentEventHandler.executeEvent(WebFormComponent.java:259)  
at org.sablo.BaseWebObject.doExecuteEvent(BaseWebObject.java:142)  
at org.sablo.BaseWebObject.executeEvent(BaseWebObject.java:131)  
at org.sablo.services.server.FormServiceHandler.executeEvent(FormServiceHandler.java:140)  
at com.servoy.j2db.server.ngclient.NGFormServiceHandler.executeEvent(NGFormServiceHandler.java:317)  
at org.sablo.services.server.FormServiceHandler.executeMethod(FormServiceHandler.java:87)  
at com.servoy.j2db.server.ngclient.NGFormServiceHandler.executeMethod(NGFormServiceHandler.java:305)  
at org.sablo.websocket.WebsocketEndpoint$3.run(WebsocketEndpoint.java:279)  
at org.sablo.eventthread.Event$1.run(Event.java:100)  
at org.sablo.websocket.CurrentWindow.runForWindow(CurrentWindow.java:77)  
at org.sablo.eventthread.Event.execute(Event.java:90)  
at org.sablo.eventthread.EventDispatcher.dispatch(EventDispatcher.java:125)  
at org.sablo.eventthread.EventDispatcher.suspend(EventDispatcher.java:236)  
at com.servoy.j2db.server.ngclient.NGRuntimeWindow.doOldShow(NGRuntimeWindow.java:475)  
at com.servoy.j2db.scripting.RuntimeWindow.doShow(RuntimeWindow.java:304)  
at com.servoy.j2db.scripting.RuntimeWindow.show(RuntimeWindow.java:298)  
at com.servoy.j2db.scripting.RuntimeWindow.showObject(RuntimeWindow.java:285)  
at com.servoy.j2db.scripting.JSWindow.js\_show(JSWindow.java:155)  
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)  
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)  
at java.lang.reflect.Method.invoke(Unknown Source)  
at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:158)  
at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:312)  
at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1774)  
at script.showFormDialog(bcore/scopes/dialog/showFormDialog:78)  
at script.exportExcel(bcore/scopes/synchronize/exportExcel:26)  
at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:837)  
at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:158)  
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:406)  
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3204)  
at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:156)  
at com.servoy.j2db.scripting.ScriptEngine.executeFunction(ScriptEngine.java:667)  
at com.servoy.j2db.server.ngclient.component.EventExecutor.executeEvent(EventExecutor.java:187)  
at com.servoy.j2db.server.ngclient.DataAdapterList.executeEvent(DataAdapterList.java:106)  
at com.servoy.j2db.server.ngclient.WebFormComponent$FormcomponentEventHandler.executeEvent(WebFormComponent.java:259)  
at org.sablo.BaseWebObject.doExecuteEvent(BaseWebObject.java:142)  
at org.sablo.BaseWebObject.executeEvent(BaseWebObject.java:131)  
at org.sablo.services.server.FormServiceHandler.executeEvent(FormServiceHandler.java:140)  
at com.servoy.j2db.server.ngclient.NGFormServiceHandler.executeEvent(NGFormServiceHandler.java:317)  
at org.sablo.services.server.FormServiceHandler.executeMethod(FormServiceHandler.java:87)  
at com.servoy.j2db.server.ngclient.NGFormServiceHandler.executeMethod(NGFormServiceHandler.java:305)  
at org.sablo.websocket.WebsocketEndpoint$3.run(WebsocketEndpoint.java:279)  
at org.sablo.eventthread.Event$1.run(Event.java:100)  
at org.sablo.websocket.CurrentWindow.runForWindow(CurrentWindow.java:77)  
at org.sablo.eventthread.Event.execute(Event.java:90)  
at org.sablo.eventthread.EventDispatcher.dispatch(EventDispatcher.java:125)  
at org.sablo.eventthread.EventDispatcher.run(EventDispatcher.java:89)  
at com.servoy.j2db.server.ngclient.eventthread.NGEventDispatcher.run(NGEventDispatcher.java:55)  
at java.lang.Thread.run(Unknown Source)  
Caused by: java.lang.RuntimeException:\[sharefoldername]\admin\_alle-relaties\_16-11-2016\_13276.xlsx cannot be created!  
at com.it2be.data.eb.a(Unknown Source)  
at com.it2be.data.eb.(Unknown Source)  
at com.it2be.data.IDExcel.a(Unknown Source)  
at com.it2be.data.IDExcel.js\_write(Unknown Source)  
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)  
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)  
at java.lang.reflect.Method.invoke(Unknown Source)  
at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:158)

---

<div class="post-metadata">

**Author:** ![patrick](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@patrick](https://forum.servoy.com/u/patrick)\
**Post date:** [November 16, 2016, 12:38pm UTC](https://forum.servoy.com/t/excel-export-and-saving-opening-file/19053/6 "2016-11-16T12:38:14Z")

</div>

Typically a server runs with the “system” account (on windows), which has no network privileges. Also I think share names are problematic, I’d rather use the UNC name (\host-name\share-name\file\_path). I’m not sure from your error where you are trying to write. \[sharefoldername]\ looks strange.

---

<div class="post-metadata">

**Author:** ![derk.hulshof](https://avatars.discourse-cdn.com/v4/letter/d/e47774/32.png) [@derk.hulshof](https://forum.servoy.com/u/derk.hulshof)\
**Post date:** [November 16, 2016, 1:07pm UTC](https://forum.servoy.com/t/excel-export-and-saving-opening-file/19053/7 "2016-11-16T13:07:40Z")

</div>

the \[sharefoldername]\ is \host-name\share-name\file\_path

I tested it with an other network user to run the service with, that solved the creation of the file
