Focal Point
Can I launch an .xls which WF did not create?

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/2571077331

April 19, 2004, 07:22 PM
Jim Brewer
Can I launch an .xls which WF did not create?
I would like to run a WebFOCUS program to create an excel file which will be used as a data source to a complicated pivot table in an existing spreadsheet. I would then like to immediately launch the complicated spreadsheet. The idea here is to do this with just one click.

Is this even possible? Any ideas?

Thanks,
Jim
April 20, 2004, 09:13 AM
<Grzegorz>
Jim,

Yes, it is possible, but not effortless.

Below are some ideas I used. If the ideas are appropriate for you - depends on the detailed requirements.
1. Embedded WF report with Excel Web Query. Described in the "Creating Reports ..." manual, chapter 8 (v 5.2).
2. Excel macro for dynamically fill the spreadsheet with data using Web query (e.g. embedding HOLD'ed HTMTABLE created with WebFOCUS)


' The syntax:
'...
urlpath = "URL;" & "The rest of the path"
Sheet.Activate
With Sheet.QueryTables.Add(Connection:=urlpath, Destination:=Sheet.Range("A1"))
.BackgroundQuery = True
.TablesOnlyFromHTML = True
.Refresh BackgroundQuery:=False
.SaveData = True
' To remove Query Table, retaining the data:
.Delete
End With
' ...

3. Windows script to run Excel "background process":


// JScript file to run with Windows Script Host.
// D:\ibi\apps\excelrun\runExcel.js
var objXL = new ActiveXObject("Excel.Application");
objXL.visible = false;
objXL.Workbooks.Open(WScript.arguments(0));

5. Skeleton of the Excel VBA macro, which opens the particular workbook, processes it, saves, and quits:

Sub processWorkbook()
' Initializatione, etc.
' ...
' Open the sophisticated spreadsheet template:
thePath = "D:\ibi\apps\tmplt\complicated.xls"
Set theWork = Workbooks.Open(thePath)
' Process theWork, filling it with WF data
' ...
' Save the result as the file visible on web server:
destPath = "Z:\path_to_webserver_directory\output.xls"
theWork.SaveAs(destPath)
theWork.Close
End Sub
'...
Private Sub Workbook_Open()
Application.DisplayAlerts = False
Call processWorkbook
Application.Quit
End Sub
6. The focexec skeleton:
[
-* Read and process report parameters, perform queries, process data, HOLD results etc., etc.:
-* ...
-* Invoke the script which creates the Excel output, using macros, templates, HOLD'ed tables, etc., etc.:
! D:\ibi\apps\excelrun\runExcel.js &WHICH_MACRO
...
-* Pass the resulting Excel to the client browser:
-HTMLFORM BEGIN


<script type="text/javascript">
function passXLS() {
window.location = "http:/webserver/the_path/output.xls";
}




-HTMLFORM END
These are just some of the "puzzle pieces". There is some additional work to do if you would like to create flexible, robust, and secure solution, but I think, that using Excel macros, Windows scripts, JavaScript and WebFOCUS you can achieve your goal, even if it is very sophisticated and specific.

Hope this helps
Grzegorz

This message has been edited. Last edited by: <Mabel>,
April 20, 2004, 06:44 PM
Jim Brewer
Excellent. I'll give it a try! Thanks.
April 28, 2004, 02:12 PM
<Pietro De Santis>
You could try this:




[/code]

This message has been edited. Last edited by: <Mabel>,