Page 1 of 2
Opening file on IFS
Posted: Mon May 16, 2011 12:18 am
by RICHARD RUTA
I'd like to open an EXCEL file on the IFS. I can do this on the C: drive:
var file = get("ExportFile"); var path = "\\program files\\microsoft office\\office12\\excel.exe c:\\temp\\" + file; alert(path); runPCCommand(path);
But I can't open the file using the command, i.e. path, below as, I think, you recommended:
var file = get("ExportFile"); var path = "\\program files\\microsoft office\\office12\\excel.exe /tiffs/" + file; alert(path); runPCCommand(path);
EXCEL opens but the file itself is not loaded.
Thanks, as always, for your help.
Re: Opening file on IFS
Posted: Mon May 16, 2011 9:58 am
by David
I see that you have an alert in there that shows the file path. What does this path look like?
Re: Opening file on IFS
Posted: Mon May 16, 2011 10:30 am
by RICHARD RUTA
Please see attached for the path that is not working.
The path that worked resolved to:
. . . \excel.exe c:\temp\boltst.csv
Re: Opening file on IFS
Posted: Mon May 16, 2011 10:42 am
by David
I see.
What you'll need to do is open the document a different way. In your example, you are calling the Excel executable using the PC command Applet. When done that way, Excel is only going to understand a local PC or mapped network drive path. It will not understand a path on the http server. If you wanted to open Excel in this way (not recommended) you'd need to map a drive to the IFS on each end user PC and use the network drive name.
To open your document without having to worry with any of that, try using this JavaScript code instead:
This function will simply link your browser to the document on the http server. It also disables the"Are you sure you want to leave this page" message while it's at it.
Your browser will open the document in Excel because it associates Excel with the ".csv" extension.
The file path from your example will work, assuming the file is actually located at:
Code: Select all
/www/profoundui/htdocs/tiffs/boltst.csv
The folder /www/profoundui/htdocs is the http server's "document root" folder, and is never given in a path. The paths are always given as if this folder is the root of the entire file system.
Re: Opening file on IFS
Posted: Mon May 16, 2011 11:51 am
by RICHARD RUTA
Sorry, Still not getting this.
Using this command:
pui.link ("/tiffs/boltst.csv");
The file opens, but not in EXCEL. And the back arrow take you to EOJ.
I think that's why I tried the PC command initially.
Re: Opening file on IFS
Posted: Mon May 16, 2011 5:34 pm
by David
I've tested this in a simple test screen and it seems to work fine -- the CSV file is opened in Excel.
Maybe the trouble is that your PC does not associate Excel with the file extension ".csv"? If you have a CSV file on your desktop, for example, does it show with an Excel icon?
Re: Opening file on IFS
Posted: Mon May 16, 2011 5:43 pm
by David
I think I see what you mean now. The technique of linking the browser to a CSV file only works in Internet Explorer. Other browsers try to show the file on their own and navigate you away from the PUI screen.
You must be using a different browser, right?
In this case, maybe calling the Excel exectuable directly is the way to go. Excel (at least 2007 or higher, I don't know if this works with earlier versions) can fetch the file from a web URL.
For example, you can set your "file" variable to something like this:
Code: Select all
http://yourServer:yourPort/tiffs/boltst.csv
Excel will then fetch the file through the http server and you will not have to worry with mapped drives or anything like that.
Does this help?
Re: Opening file on IFS
Posted: Mon May 16, 2011 6:04 pm
by RICHARD RUTA
I switched to Explorer from Google Chrome and tried to run the command. I got the message asking if I wanted to navigate away from the page. Even saying 'yes' did not get me anywhere. By the way, Explorer is not an option.
Re: Opening file on IFS
Posted: Mon May 16, 2011 9:48 pm
by RICHARD RUTA
I tried the IP address and port as I understand them and got nowhere. Would you give me an example of what the syntax of "//yourServer:yourPort/" should look like?
Re: Opening file on IFS
Posted: Tue May 17, 2011 8:54 am
by David
Using MS Office 2007 Excel, I was able to have it open a web URL by passing something like this to the Excel executable:
Code: Select all
http://myiSeries:8080/tiffs/boltst.csv