16
Graphical RPG Framework for IBM i SilverDev Tutorial Export to Excel, PDF and HTML

[Tutorial] IBM i Apps: Export to Excel, PDF & HTML with SilverDev

Embed Size (px)

Citation preview

Graphical RPG Framework for IBM i

SilverDev Tutorial Export to Excel, PDF and HTML

SilverDev Tutorial – Export to Excel, PDF and HTML

Experia -- Reproduction Rights Reserved -- 2 / 16

Steps:

1. Menu Creation ...................................................................................................................................... 4 2. Add OnClick Events ............................................................................................................................... 6 3. Export to Excel ...................................................................................................................................... 7 4. Export to PDF ........................................................................................................................................ 8 5. Export to HTML ..................................................................................................................................... 9 6. Save and compile the screen .............................................................................................................. 10 7. RPG source compilation ...................................................................................................................... 11 8. Result .................................................................................................................................................. 12 9. More: Export options .......................................................................................................................... 13 10. More: Select columns to export.......................................................................................................... 14 11. More: Add icons .................................................................................................................................. 15

SilverDev Tutorial – Export to Excel, PDF and HTML

Experia -- Reproduction Rights Reserved -- 3 / 16

This tutorial assumes you have already followed SilverDev Tutorial « Grid and Pop-up Menu ». The application displays a books list, their IDs and respective prices. We’ll add it a menu for the user to choose the format he wants to export the grid data.

Open the application in SilverDev Designer:

SilverDev Tutorial – Export to Excel, PDF and HTML

Experia -- Reproduction Rights Reserved -- 4 / 16

1. Menu Creation

In the Components tab, select CMainMenu Place it on the screen, double click it to open the Menu Designer. Right click to add a new item

Right click to create a sub menu. Add 3 items.

SilverDev Tutorial – Export to Excel, PDF and HTML

Experia -- Reproduction Rights Reserved -- 5 / 16

Rename the components:

For each component, select it and, in the Inspector tab, change Caption and Name properties. Display, in Caption: « Export », « Excel », « PDF » et « HTML ». Name it, respectively, in: « ItemExport », « ItemExcel », « ItemPDF » et « ItemHTML ».

SilverDev Tutorial – Export to Excel, PDF and HTML

Experia -- Reproduction Rights Reserved -- 6 / 16

2. Add OnClick Events

We add an OnClick Event on each sub menu element:

Select the menu element to click and go on the Inspector’s Event tab

Select and double click OnClick

The cursor is now in the source in the itemExcel_Onclick event. Do the same for ItemPDF and ItemHTML elements.

Tip: Press F10 to display the screen

SilverDev Tutorial – Export to Excel, PDF and HTML

Experia -- Reproduction Rights Reserved -- 7 / 16

3. Export to Excel Enter the following code under ItemExcel_Onclick event description. Use sdSet funtion to define the export type:

sdSet(F1:'SFL1':'ExportOptions.TypeExport':'exXLSX');

Then export the content of SFL1 grid component:

sdExport(F1:'SFL1');

SilverDev Tutorial – Export to Excel, PDF and HTML

Experia -- Reproduction Rights Reserved -- 8 / 16

4. Export to PDF Enter the following code under ItemPDF_Onclick event description. Use sdSavePdf funtion to export the content of SFL1 component: sdSavePdf(F1:'SFL1');

SilverDev Tutorial – Export to Excel, PDF and HTML

Experia -- Reproduction Rights Reserved -- 9 / 16

5. Export to HTML Enter the following code under ItemHTML_Onclick event description. Use sdSet funtion to define the export type:

sdSet(F1:'SFL1':'ExportOptions.TypeExport':'exHtml');

Then export the content of SFL1 grid component:

sdExport(F1:'SFL1');

SilverDev Tutorial – Export to Excel, PDF and HTML

Experia -- Reproduction Rights Reserved -- 10 / 16

6. Save and compile the screen

Save and compile the screen on the Form Menu: We have already saved this screen on the previous tutorial: don’t forget to tick “Overwrite the existing object”

SilverDev Tutorial – Export to Excel, PDF and HTML

Experia -- Reproduction Rights Reserved -- 11 / 16

7. RPG source compilation

Save your modifications with this button or via the Member/Save member Menu

Compile the program using the “Compiling/Generate program” menu.

SilverDev Tutorial – Export to Excel, PDF and HTML

Experia -- Reproduction Rights Reserved -- 12 / 16

8. Result

Your application has been updated on MyDesk.

Double-Click to launch it.

SilverDev Tutorial – Export to Excel, PDF and HTML

Experia -- Reproduction Rights Reserved -- 13 / 16

9. More: Export options

Select CSFL grid element and, in the properties tab / ExportOptions, turn ShowDialog property to True

When the user exports the grid, this dialog box will be displayed:

SilverDev Tutorial – Export to Excel, PDF and HTML

Experia -- Reproduction Rights Reserved -- 14 / 16

10. More: Select columns to export

Double click CSFL component

to open this dialog box: We don’t want to export IDs.

Select it and, in the Inspector tab, turn its Exportable property to False

Save and compile. The user can no longer select the ID column to export it.

SilverDev Tutorial – Export to Excel, PDF and HTML

Experia -- Reproduction Rights Reserved -- 15 / 16

11. More: Add icons

In the Menu Designer, select the menu element where you want to add an icon

In the Inspector tab, use its Bitmap property.

Click « … » to load an icon from your PC. The icon must be in .bmp format

Recommended picture size: 16x16 pixels.

Save and compile

SilverDev Tutorial – Export to Excel, PDF and HTML

Experia -- Reproduction Rights Reserved -- 16 / 16

More info on www.silverdev.com

EXPERIA Europe 4, rue L.Beridot

Les jardins d'Epione 38500 VOIRON - FRANCE

www.experia.com [email protected]