excel export and saving / opening file

Forum to discuss the new web client version of Servoy.

excel export and saving / opening file

Postby derk.hulshof » Wed Nov 16, 2016 1:08 pm

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
derk.hulshof
 
Posts: 108
Joined: Tue Dec 03, 2013 9:18 am
Location: Netherlands

Re: excel export and saving / opening file

Postby patrick » Wed Nov 16, 2016 2:05 pm

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. It explains the differences in file handling between smart and web client.
Patrick Ruhsert
Servoy DACH
patrick
 
Posts: 3703
Joined: Wed Jun 11, 2003 10:33 am
Location: Munich, Germany

Re: excel export and saving / opening file

Postby derk.hulshof » Wed Nov 16, 2016 2:07 pm

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.
derk.hulshof
 
Posts: 108
Joined: Tue Dec 03, 2013 9:18 am
Location: Netherlands

Re: excel export and saving / opening file

Postby patrick » Wed Nov 16, 2016 2:10 pm

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.
Patrick Ruhsert
Servoy DACH
patrick
 
Posts: 3703
Joined: Wed Jun 11, 2003 10:33 am
Location: Munich, Germany

Re: excel export and saving / opening file

Postby derk.hulshof » Wed Nov 16, 2016 2:32 pm

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.<init>(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)
derk.hulshof
 
Posts: 108
Joined: Tue Dec 03, 2013 9:18 am
Location: Netherlands

Re: excel export and saving / opening file

Postby patrick » Wed Nov 16, 2016 2:38 pm

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.
Patrick Ruhsert
Servoy DACH
patrick
 
Posts: 3703
Joined: Wed Jun 11, 2003 10:33 am
Location: Munich, Germany

Re: excel export and saving / opening file

Postby derk.hulshof » Wed Nov 16, 2016 3:07 pm

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
derk.hulshof
 
Posts: 108
Joined: Tue Dec 03, 2013 9:18 am
Location: Netherlands


Return to Servoy NGClient

Who is online

Users browsing this forum: No registered users and 6 guests

cron