Focal Point
[SOLVED] Saving Excel File to Location with Multiple Worksheets

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

January 26, 2016, 12:06 PM
jcannavo
[SOLVED] Saving Excel File to Location with Multiple Worksheets
Hello,

I have a FEX with two reports and each report output I'm placing in an Excel file on different worksheets.

I'm using this in the first report to open the Excel file:
ON TABLE PCHOLD FORMAT XLSX OPEN

Then to close that out on the second report i'm using:
ON TABLE PCHOLD FORMAT XLSX CLOSE

Now this works fine and dandy to run it and have the prompt come up to save or open the file, however I need to instead post this file to a location rather than prompt.

Usually when I have a singular worksheet report I use the following to save the file to location:
ON TABLE SAVE FILENAME
'\\filepath\Temp\ReportNAME.._&YYMD...xlsx'
FORMAT XLSX

I have yet to find the solution by research and I'm having trouble figuring out how to combine the PCHOLD way to allow for the multiple worksheets and still save off the file. Anyone have any sugestions or know what I need to do to save off the file to a location when posting to multiple worksheets in this fashion? Or is there a totally different way I should be doing this?

Thanks,
Joe

This message has been edited. Last edited by: jcannavo,


JC
WebFOCUS Dev Studio / App Studio
8.2.01
Windows 7
January 26, 2016, 12:25 PM
BabakNYC
You could try FILEDEF to map the hold file name to a physical disk file.

FILEDEF TEST_XLS DISK e:\temp\test_xls.xlsx

TABLE FILE CAR
PRINT CAR BY COUNTRY
WHERE COUNTRY EQ 'ENGLAND';
ON TABLE HOLD AS TEST_XLS FORMAT XLSX
END


WebFOCUS 8206, Unix, Windows
January 26, 2016, 01:18 PM
Tom Flynn
Filedef the file, then, use EDAGET to display to user.
Search on EDAGET


Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe
January 27, 2016, 09:45 AM
jgelona
We do this all the time using OS copy commands or secure copy. Our .fex look like this:
TABLE FILE ....
ON TABLE PCHOLD FORMAT XLSX OPEN
END
...
TABLE FILE ....
ON TABLE HOLD AS FINAL FORMAT XLSX CLOSE
END
-RUN
-UNIX cp final.xlsx &APPROOT/reports


We like to copy to client server. That way we can put a link on the dashboard (not portal) and users can open the report whenever they want. Reports will generally refresh daily or several time a day. This uses scp (secure copy) and looks like this:
-UNIX scp final.xlsx $WFUSER@$WFCLIENT:$WFAPP/baseapp


$WFUSER is a Linux environment variable that is a user id that access to the client server
$WFCLIENT is a Linux environment variable that is the server name
$WFAPP is a Linux environment variable that contains the path

Also note that the CLOSE uses HOLD not PCHOLD. This write the final file into the working directory, generally edatemp unless you are using APP HOLD to hold files somewhere else.


In FOCUS since 1985. Prod WF 8.0.08 (z90/Suse Linux) DB (Oracle 11g), Self Serv, Report Caster, WebServer Intel/Linux.
January 27, 2016, 04:31 PM
jcannavo
Hello,

FILEDEF was definitely the way to go. Thanks guys!

Solution Code:

FILEDEF THE_FILE DISK '\\filepath\Temp\ReportNAME.._&YYMD...xlsx'
-RUN

TABLE FILE CAR
...
ON TABLE HOLD AS THE_FILE FORMAT XLSX OPEN
...
END

TABLE FILE CAR
...
ON TABLE HOLD AS THE_FILE FORMAT XLSX CLOSE
...
END

Thanks for the insight!

Joe


JC
WebFOCUS Dev Studio / App Studio
8.2.01
Windows 7