Focal Point
[SOLVED] select output format of a report in an HTML page

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

October 03, 2017, 11:32 AM
Badr.A
[SOLVED] select output format of a report in an HTML page
Hi There,
working on an HTML page that display a report, and I need to add an option for the user to download Excel file of the report in their pc's, anyone can give me ideas how it can be done please?

This message has been edited. Last edited by: FP Mod Chuck,


WebFocus App Studio
V8201
October 03, 2017, 11:43 AM
MartinY
Would you want this option AFTER the report is produced or BEFORE ?

BEFORE, have this in your code :
ON TABLE PCHOLD FORMAT &WFFMT.(<HTML Web Document (HTML),HTML>,<Portable Document Format (PDF),PDF>,<Excel,XLSX>).Select type of display output.

This gives option to output in HTML, Excel or PDF

AFTER, have this in your code but you will need to have ALL parameters properly sent and note that I call back the same fex that have originally produce the report : it call itself.
This is one option where the save Excel option is placed in the Header (could be almost anywhere)
-IF &WFFMT NE 'HTML' OR 'PDF' THEN GOTO :NODRILL;
TYPE=HEADING,
     LINE=5,
     OBJECT=TEXT, ITEM=1, SIZE=10, JUSTIFY=LEFT, COLOR=RGB(8 97 74),
     FOCEXEC=IBFS:/WFC/Repository/<app>/<SameFExNameAsOriginalOne.fex>( \
     PR1=&PR1.QUOTEDSTRING \
     PR2=&PR2.QUOTEDSTRING \
     PR3=&PR3.QUOTEDSTRING \
     PR4=&PR4.QUOTEDSTRING \
     COMPANYID=&COMPANYID.QUOTEDSTRING \
     WFFMT='XLSX'),
     TARGET='_blank',
$
-:NODRILL


Sample 1
TABLE FILE CAR
SUM RETAIL_COST
BY COUNTRY
BY CAR
ON TABLE PCHOLD FORMAT &WFFMT.(<HTML Web Document (HTML),HTML>,<Portable Document Format (PDF),PDF>,<Excel,XLSX>).Select type of display output.
END


Sample 2
-DEFAULTH &WFFMT = 'HTML'
TABLE FILE CAR
SUM RETAIL_COST
BY COUNTRY
BY CAR
WHERE COUNTRY EQ '&CNTRY';

HEADING
"Save As Excel"

ON TABLE PCHOLD FORMAT &WFFMT

ON TABLE SET STYLE *
     INCLUDE = IBFS:/EDA/EDASERVE/_EDAHOME/ETC/endeflt.sty,
$
-IF &WFFMT NE 'HTML' OR 'PDF' THEN GOTO :NODRILL;
TYPE=HEADING,
     LINE=1,
     OBJECT=TEXT, ITEM=1, SIZE=10, JUSTIFY=LEFT, COLOR=RGB(8 97 74),
     FOCEXEC=IBFS:/WFC/Repository/IT/AAAA.fex( \
     CNTRY=&CNTRY.QUOTEDSTRING \
     WFFMT='XLSX'),
     TARGET='_blank',
$
-:NODRILL
ENDSTYLE
END
-EXIT

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


WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
October 03, 2017, 11:55 AM
Badr.A
It is After the report is produce, I'll try it.

thank you


WebFocus App Studio
V8201
October 03, 2017, 12:04 PM
Badr.A
I'm trying to make the option of downloading the Excel file after a user select the radio button and select download?
quote:
Originally posted by MartinY:
Would you want this option AFTER the report is produced or BEFORE ?

BEFORE, have this in your code :
ON TABLE PCHOLD FORMAT &WFFMT.(<HTML Web Document (HTML),HTML>,<Portable Document Format (PDF),PDF>,<Excel,XLSX>).Select type of display output.

This gives option to output in HTML, Excel or PDF

AFTER, have this in your code but you will need to have ALL parameters properly sent and note that I call back the same fex that have originally produce the report : it call itself.
This is one option where the save Excel option is placed in the Header (could be almost anywhere)
-IF &WFFMT NE 'HTML' OR 'PDF' THEN GOTO :NODRILL;
TYPE=HEADING,
     LINE=5,
     OBJECT=TEXT, ITEM=1, SIZE=10, JUSTIFY=LEFT, COLOR=RGB(8 97 74),
     FOCEXEC=IBFS:/WFC/Repository/<app>/<SameFExNameAsOriginalOne.fex>( \
     PR1=&PR1.QUOTEDSTRING \
     PR2=&PR2.QUOTEDSTRING \
     PR3=&PR3.QUOTEDSTRING \
     PR4=&PR4.QUOTEDSTRING \
     COMPANYID=&COMPANYID.QUOTEDSTRING \
     WFFMT='XLSX'),
     TARGET='_blank',
$
-:NODRILL


Sample 1
TABLE FILE CAR
SUM RETAIL_COST
BY COUNTRY
BY CAR
ON TABLE PCHOLD FORMAT &WFFMT.(<HTML Web Document (HTML),HTML>,<Portable Document Format (PDF),PDF>,<Excel,XLSX>).Select type of display output.
END


Sample 2
-DEFAULTH &WFFMT = 'HTML'
TABLE FILE CAR
SUM RETAIL_COST
BY COUNTRY
BY CAR
WHERE COUNTRY EQ '&CNTRY';

HEADING
"Save As Excel"

ON TABLE PCHOLD FORMAT &WFFMT

ON TABLE SET STYLE *
     INCLUDE = IBFS:/EDA/EDASERVE/_EDAHOME/ETC/endeflt.sty,
$
-IF &WFFMT NE 'HTML' OR 'PDF' THEN GOTO :NODRILL;
TYPE=HEADING,
     LINE=1,
     OBJECT=TEXT, ITEM=1, SIZE=10, JUSTIFY=LEFT, COLOR=RGB(8 97 74),
     FOCEXEC=IBFS:/WFC/Repository/IT/AAAA.fex( \
     CNTRY=&CNTRY.QUOTEDSTRING \
     WFFMT='XLSX'),
     TARGET='_blank',
$
-:NODRILL
ENDSTYLE
END
-EXIT



WebFocus App Studio
V8201
October 09, 2017, 11:12 AM
FP Mod Chuck
Badr.A

So do you want the report to display based on the selection from the radio button and then another button to download as Excel?


Thank you for using Focal Point!

Chuck Wolff - Focal Point Moderator
WebFOCUS 7x and 8x, Windows, Linux All output Formats
October 10, 2017, 08:38 AM
MartinY
Badr,

Using first sample will ask the user to select the output type before producing the report.

Using my second sample will ask the user to first have to select parameter to then produce the report and once the report is produced can click on "Save As Excel" to download the report in Excel.

Not clear what you are asking since my second sample already answered what you've asked
quote:

It is After the report is produce,


quote:

I'm trying to make the option of downloading the Excel file after a user select the radio button and select download?

If you want the user to select from a radio button, it has to be BEFORE the report is produced. radio appears on a HTML page not in the report itself.
The other option would be to have an HTML page with a radio for the output option default to HTML and with an iFrame which display the report after the user have select its parameter and press "Produce Report".
Then if user change the output selection from HTML to Excel an press again "Produce Report", the report will then be executed in Excel in a new window.


WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
October 10, 2017, 02:16 PM
Tom Flynn
Badr.A,
Here is an example with Excel image used as a drilldown.
Copy code into baseapp/car_report.fex
Copy/Get the image and place into an images folder under applications.

Run it and see if it is what you are looking for...

Tom
-DEFAULT &OUTPUT = 'HTML'
DEFINE FILE CAR
  EXCEL_IMG/A200 = '<IMG SRC=/approot/images/excel.gif border=0 HEIGHT=20 WIDTH=20>';
END
TABLE FILE CAR
HEADING
"Information Builders Car Data"
SUM
   DEALER_COST/P9.2MC AS 'Dealer Cost'
   RETAIL_COST/P9.2MC AS 'Retail Cost'
    COMPUTE PROFIT/P9.2MC = RETAIL_COST - DEALER_COST; AS 'Profit'
  BY COUNTRY AS 'Country'
  BY CAR     AS 'Car'
  BY MODEL   AS 'Model'
 ON TABLE PCHOLD FORMAT &OUTPUT
 ON TABLE SET PAGE-NUM OFF
-*******************
-IF &OUTPUT NE 'HTML' GOTO SKIP_IMAGE;
-*******************
 ON TABLE SET HTMLCSS ON
 ON TABLE SUBHEAD
"<EXCEL_IMG "
-*******************
-SKIP_IMAGE
-*******************
ON TABLE SET STYLE *
 UNITS=IN, GRID=ON, $
TYPE=HEADING, JUSTIFY=CENTER, BACKCOLOR='LIGHT BLUE', COLOR=BLACK, STYLE=BOLD, BORDER=1, $
TYPE=DATA, GRID=ON, BORDER=LIGHT,$
TYPE=TITLE, STYLE=BOLD, BORDER=LIGHT, BACKCOLOR=BLACK, COLOR=WHITE,$
-*******************
-IF &OUTPUT NE 'HTML' GOTO SKIP_DRILL;
-*******************
TYPE=TABHEADING, JUSTIFY=RIGHT,
    FOCEXEC=baseapp/car_report.fex (OUTPUT = 'EXL07'),
	TARGET='_blank',
	ALT='Output to EXCEL',$
-*******************
-SKIP_DRILL
-*******************
ENDSTYLE
END
-EXIT

Excel Image

This message has been edited. Last edited by: Tom Flynn,


Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe