hssfcgi developer guide last modified on january 1, 2021 · 2021. 4. 11. · hssfcgi a simple way...

68
HSSFCGI A simple way to create Spreadsheets with HSSFR4 by Giovanni B. Perotti (Italy) About it Prerequisites Installation Maintenance HTTP instance The XLSGEN language Right to left 1-About it From Wikipedia: Apache POI, a project run by the Apache Software Foundation, and previously a sub-project of the Jakarta Project, provides pure Java libraries for reading and writing files in Microsoft Office formats, such as Word, PowerPoint and Excel. A subcomponent of this project is HSSF. Wikipedia: HSSF (Horrible SpreadSheet Format) – reads and writes Microsoft Excel (XLS) format files. It can read files written by Excel 97 onwards; this file format is known as the BIFF 8 format. (As the Excel file format is complex and contains a number of tricky characteristics, some of the more advanced features cannot be read. For example, POI is unable to open spreadsheets that have filters or views.) In the last few years (2004 to 2010), Scott Klement has developed and maintained some free System i ILE-RPG service program, named HSSFR4. By interfacing HSSF POI Java classes, HSSFR4 offers facilities (ILE-RPG subprocedures) to create even complex Excel spreadsheets. In this way, it is now possible to have - on IBM i - ILE-RPG programs creating Excel spreadsheet. Information about HSSFR4 can be found in a Scott Klement's presentation (PDF) going through several articles by Scott, that I have collected. In addition to HSSFR4 subprocedures, you can develop your ones by referring to the Developers' Guide to HSSF and XSSF page. Learn how to do it from Scott's HSSFR4 prototypes. In April 2009, after trying with success Scott Klement's HSSFR4, I came to the following conclusion: Interfacing HSSFR4 directly from an ILE-RPG program, in order to create a given spreadsheet - though results may be impressive - requires some medium- high programming ability and may need some relevant debugging effort. XLSGEN language I then decided to develop an XML-like language able to support spreadsheet creation. It would be interpreted by an ILE-RPG program, providing the necessary interfaces to HSSFR4 subprocedures. Though supporting only some of the most common HSSFR4 subprocedures, this language would allow: To quickly create manually an XML-like script able to generate a prototype spreadhsheet, useful in verifying development assumptions. 1. Once satisfied by the manual XML-like script, to write a rather conventional program on the IBM i that would generate such XML-like script and would call the script interpreter. 2. Worth to be noted that such conventional spreadsheet-creating program could be written in any language available on the IBM i, such COBOL, RPG, C and even ... Java. 3. Such an XML-like language is now available, it is named XLSGEN and is interpreted through command HSSFCGI/XLSGEN. While in the next pages we provide details on this language, you may immediately get some ideas about it by running the following examples: spreadsheet created from this XLSGEN XML-like script 1.xls 1.txt 2.xls 2.txt TABLEXLS command Using the XLSGEN language, a general purpose command, named TABLEXLS, has been developed. This command allows to generate an XLS (Microsoft Office 2003) or XLSX (Microsoft Office 2007) Excel spreadsheet from any database file. This command can be run in interactive mode, in batch mode and ... even from a WEB browser. XLSUPD and XLSXUPD commands With these commands you may update a XLS or a XLSX Excel spreadsheet. A XLSGEN-like stream file is used to provide statements about cells to be updated. Important notes All the following are loaded on the IBM i during installation of library HSSFCGI: POI Java classes HSSFR4 service programs, both the version for POI 3.2 (Excel 2003) and the version for POI 3.6 (Excel 2007). XLSGEN interpreter 1. HSSF allows to imbed pictures in a spreadsheet. Once imbedded, the images are "hard-coded" in the spreadsheet, and do not need to reference the original images. HSSFR4 supports this feature. So does XLSGEN. 2. t s La on d e odifi m HSSFCGI Developer Guide 1 January 1, 2021

Upload: others

Post on 17-May-2021

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

HSSFCGI

A simple way to create Spreadsheets with HSSFR4

by Giovanni B. Perotti (Italy)

About itPrerequisitesInstallationMaintenanceHTTP instanceThe XLSGEN languageRight to left

1-About it

From Wikipedia: Apache POI, a project run by the Apache Software Foundation, and previously a sub-project of the Jakarta Project, provides pure Java libraries forreading and writing files in Microsoft Office formats, such as Word, PowerPoint and Excel.

A subcomponent of this project is HSSF.Wikipedia: HSSF (Horrible SpreadSheet Format) – reads and writes Microsoft Excel (XLS) format files. It can read files written by Excel 97 onwards; this file format isknown as the BIFF 8 format.(As the Excel file format is complex and contains a number of tricky characteristics, some of the more advanced features cannot be read. For example, POI is unable to open spreadsheets that have filters orviews.)

In the last few years (2004 to 2010), Scott Klement has developed and maintained some free System i ILE-RPG service program, named HSSFR4.By interfacing HSSF POI Java classes, HSSFR4 offers facilities (ILE-RPG subprocedures) to create even complex Excel spreadsheets. In this way, it is now possible tohave - on IBM i - ILE-RPG programs creating Excel spreadsheet.Information about HSSFR4 can be found

in a Scott Klement's presentation (PDF)going through several articles by Scott, that I have collected.

In addition to HSSFR4 subprocedures, you can develop your ones by referring to the Developers' Guide to HSSF and XSSF page. Learn how to do it from Scott'sHSSFR4 prototypes.

In April 2009, after trying with success Scott Klement's HSSFR4, I came to the following conclusion:Interfacing HSSFR4 directly from an ILE-RPG program, in order to create a given spreadsheet - though results may be impressive - requires some medium-high programming ability and may need some relevant debugging effort.

XLSGEN languageI then decided to develop an XML-like language able to support spreadsheet creation. It would be interpreted by an ILE-RPG program, providing the necessaryinterfaces to HSSFR4 subprocedures.Though supporting only some of the most common HSSFR4 subprocedures, this language would allow:

To quickly create manually an XML-like script able to generate a prototype spreadhsheet, useful in verifying development assumptions.1. Once satisfied by the manual XML-like script, to write a rather conventional program on the IBM i that would generate such XML-like script and wouldcall the script interpreter.

2.

Worth to be noted that such conventional spreadsheet-creating program could be written in any language available on the IBM i, such COBOL, RPG,C and even ... Java.

3.

Such an XML-like language is now available, it is named XLSGEN and is interpreted through command HSSFCGI/XLSGEN.While in the next pages we provide details on this language, you may immediately get some ideas about it by running the following examples:

spreadsheetcreated fromthis XLSGEN

XML-like script1.xls 1.txt2.xls 2.txt

TABLEXLS commandUsing the XLSGEN language, a general purpose command, named TABLEXLS, has been developed.This command allows to generate an XLS (Microsoft Office 2003) or XLSX (Microsoft Office 2007) Excel spreadsheet from any database file.This command can be run in interactive mode, in batch mode and ... even from a WEB browser.

XLSUPD and XLSXUPD commandsWith these commands you may update a XLS or a XLSX Excel spreadsheet. A XLSGEN-like stream file is used to provide statements about cells to beupdated.

Important notesAll the following are loaded on the IBM i during installation of library HSSFCGI:

POI Java classesHSSFR4 service programs, both the version for POI 3.2 (Excel 2003) and the version for POI 3.6 (Excel 2007).XLSGEN interpreter

1.

HSSF allows to imbed pictures in a spreadsheet. Once imbedded, the images are "hard-coded" in the spreadsheet, and do not need to reference the originalimages. HSSFR4 supports this feature. So does XLSGEN.

2.

tsLa on deodifim

HSSFCGI Developer Guide

1

January 1, 2021

Page 2: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

2-Prerequisites

Compiler ILE RPG IV, product 57xxWDS, opt. 31 - Necessary to install the product and to run command XLSTABLELibrary QSYSINC, product 57xx-SS1, opt. 13 - Necessary to build Scott Klement's service program HSSFR4.Library QSHELL, product 57xx-SS1, opt. 30Library QPASE, product 57xx-SS1, opt. 33If you want to create just XLS (Office 2003) Excel spreadsheets, you need

Microsoft Office 2003 or subsequentOS/400 release V5R3 or subsequentLibrary QJAVA, product 57xx-JV1, opt. 6 (Java 1.4) or opt. 7 (Java 1.5) or subsequent.

If you want to create also XLSX (Office 2007) Excel spreadsheets, you needMicrosoft Office 2007 or subsequentOS/400 release or subsequentLibrary QJAVA, product 57xx-JV1, opt. 7 (Java 1.5) or subsequent.

For more information on IBM i 57xxJV1 product options vs OS/400 releases, see this page.Optional prerequisite - HSSFCGI includes a command (ZIPWKB) to zip Excel workbooks into a stream file. This command requires installation of theEasy400.net distributed utility ZIP.

3-Installation

Remove any POI-related and any XLPARSE-related objects from /QIBM/userdata/Java400/ext.Adding such Java objects to this directory is a bad practice and should be discontinued.Leaving such objects in /QIBM/userdata/Java400/ext causes RPG programs, trying to use POI, to receive a nasty Java exception... java/lang/NoSuchMethodError: ...Read Scott Klement's recommendation!Do the following:

After installing HSSFCGI, run command WRKLNK '/hssfcgi/java/*'and take a note of all the subdirectories there.

i.

Then run command WRKLNK '/QIBM/UserData/Java400/ext'and make sure that no such subdirectories exist in the /QIBM/UserData/Java400/ext directory.

ii.

If you already installed a previous version of library HSSFCGI, rename it HSSFCGIOLD.You may delete library HSSFCGIOLD upon successful installation of the new version of library HSSFCGI.Download file hssfcgi.zip from the Easy400 download page and unzip it.Follow the HSSFCGI.txt instructions to upload and to restore library HSSFCGI.On the IBMi run the following procedure:STRREXPRC SRCMBR(INSTALL) SRCFILE(HSSFCGI/QREXSRC) .It does the following:

creates Scott Klement's service program HSSFR4_1 (POI 3.2), service program HSSFR4_2 (POI 3.6) and related demos in library HSSFCGI.Sources are stored in source files HSSFCGI/QRPGLESRC1 and HSSFCGI/QRPGLESRC2.creates programs XLSGEN (the XLSGEN interpreter) and TABLEXLScreates XLSGEN demo programs GUB and FAMACCcreates and populates library HSSFCGIDTA (used to store your TABLEXLS data)restores IFS directory /hssfcgi, which includes Java classes for POI 3.2, POI 3.6, etc.displays the HTTP directives that you may install on an Apache HTTP instance of yours.[You may later on display again this HTTP directives with commandDSPF STMF('/HSSFCGI/apache/http_directives.txt') ]

To validate the installation, run command span class="code">HSSFCGI/VALIDATE .If the validation is successful, message "HSSFCGI installation was validated" is displayed.

Note 1- Replicating HSSFCGI installation on another boxIf the target system runs an OS/400 release VxRyMz lower that the source system one, on the source system you must first re-create the HSSFCGI programswith commandSTRREXPRC SRCMBR(INSTALL) SRCFILE(HSSFCGI/QREXSRC) PARM(VxRyMz)

a.

On the source system save libraries HSSFCGI and HSSFCGIDTA (specify parameter TGTRLS if needed)b. On the target system restore libraries HSSFCGI and HSSFCGIDTAc. On the target system run command HSSFCGI/INSTALL to complete the setup.d.

4-MaintenanceThis utility is maintained on request, both for applying fixes and for adding enhancements. Send your requests to the author. To know what is new, just take a look at its Change Log.

5-HTTP instance

HTTP INSTANCEIn case where

you do not want to modify an exsiting HTTP instance, oryou prefer to have a separate HTTP instance to run this utility, oryou have no experience in handling HTTP instancesyou may follow our instructions to create an HTTP instance named HSSFCGI.

It listens on port 8016.Its configuration directives are in the IFS stream file /hssfcgi/conf/httpd.conf .This is how you create and use this HTTP instance:

run the following command to create the HTTP instance HSSFCGI (which listens on port 8016):CPYF FROMFILE(HSSFCGI/QATMHINSTC) TOFILE(QUSRSYS/QATMHINSTC)FROMMBR(HSSFCGI) TOMBR(HSSFCGI) MBROPT(*REPLACE) CRTFILE(*YES)

i.

run the following command to start the HTTP instance HSSFCGI:STRTCPSVR *HTTP HTTPSVR(HSSFCGI)

ii.

to run TABLEXLS, use the following URL:http://...:8016/tablexls

iii.

1.

RESTRICTING THE ACCESS TO THIS UTILITY The last group of HTTP directives in IFS stream file /hssfcgi/conf/httpd.conf performs user validation vs thesystem user profiles.This is a convenient way of restricting the access to the user profiles having the proper rights for accessing a given database file.However, if you do not like to enable all user profiles to access TABLEXLS, you may decide to use instead a validation list in order to restrict the access to agiven set of user names.This is how you do it:

Create a validation listCRTVLDL VLDL(QGPL/xxx) AUT(*EXCLUDE)GRTOBJAUT OBJ(QGPL/xxx) OBJTYPE(*VLDL) USER(QTMHHTTP QTMHHTP1) AUT(*USE)

i.

2.

HSSFCGI Developer Guide

2

V6R1

Page 3: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

where xxx is the name of your validation list.Use HTTP instance ADMIN to add/update entries to this validation list:

STRTCPSVR SERVER(*HTTP) HTTPSVR(*ADMIN)span class="code">http://...:2001click link IBM Web Administration for iSeriespress the Advanced tabpress the Internet Users and Groups tabselect one of the following:

Add Internet UserChange Internet User PasswordDelete Internet User

specify your validation list as library_name/validation_list_name.

ii.

From a 5250 session enter commandEDTF '/hssfcgi/conf/httpd.conf'to update the HSSFCGI HTTP instance configuration file, and replace the last group of directives as follow:# The following group of directives is for user validation vs the system user profiles

AuthType BasicAuthName "HSSFCGI reserved tools"PasswdFile QGPL/XXXUserID YYYRequire valid-user

whereXXX is the name of your validation listYYY is the name of an user profile of your choice.User profiles QTMHHTTP and QTMHHTP1 should be granted for its *USE.

iii.

Restart the HSSFCGI HTTP instance:STRTCPSVR SERVER(*HTTP) RESTART(*HTTP) HTTPSVR(HSSFCGI)

iv.

6-The XLSGEN languageThe XLSGEN language is the core of HSSFCGI. It is a rather simple XML-like language, that allows to generate XLS or XLSX Excel spreadsheets.It is explained in the next page.

7-Right To LeftHSSFCGI includes a feature that forces generated worksheets to display their columns from right to left, instead of from left to right.Read about it at this page.

HSSFCGI Developer Guide

3

Page 4: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

Last modified on 09/21/2019 22:58:33

HSSFCGIThe XLSGEN language

The XLSGEN commandA prototypeThe XLSGEN syntaxMore on ...Large worksheetsCommand ZIPWKBError recordingCreating an XLS/XLSX stream file from a program

The XLSGEN commandThe XLSGEN language is a rather simple XML-like language, that allows to generate XLS or XLSX Excel spreadsheets.

The XLSGEN script must be done in an IFS stream file and input-ed either to command HSSFCGI/XLSGEN:

XLS generator (XLSGEN) Type choices, press Enter.

Input XML stream file . . . . . INPSTMF Output XLS stream file . . . . . OUTSTMF Add Sheets to existing WkBook . ADDTO *NO *NO, *YES Decimal positions . . . . . . . DECPOS *AUTO 0-9, *AUTO, *NOC Display zero values . . . . . . ZERODSP *YES *YES, *NO Negative numbers format . . . . NEGFMT *A *A, *B, *C Format all date cells as . . . . CVTDATE *NO *NO, *MDY, *DMY, *YMD... Null date display option . . . . NULLDATE *SAME *SAME, *BLANK, *SKIP Format all time cells as . . . . CVTTIME *NO *NO, *HMS, *ISO, ... Null time display option . . . . NULLTIME *SAME *SAME, *BLANK, *SKIP Skip blank cells . . . . . . . . SKPBLANK *NO 1-999, *NO, *YES + for more values Initial rows to be frozen . . . FROZEN 0 Number

HSSFCGI Developer Guide

4

perotti
Highlight
Page 5: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

ColHdg background color . . . . HDGCOLOR *NONE Default cell colors: DFTCELLCOL Font color . . . . . . . . . . BLACK Background color . . . . . . . WHITE Cell border . . . . . . . . . . CELLBORDER *NO *NO, *YES, *COLOR, *FCOLOR... Generate log . . . . . . . . . . LOG *NO *YES, *NO Generate XLSGEN report . . . . . XLSGENRPT *YES *YES, *NO Sizing parameters . . . . . . . SHEETSIZE Max no. of cells per workbook 2300000 10000-2300000 Max no. of sheets per workbook *AUTO *AUTO, number Run identifier . . . . . . . . . RUNID *NONE Run it in a submitted job . . . SBMJOB *NO *YES, *NO

Figure 1a - Command HSSFCGI/XLSGEN

or to command HSSFCGI/XLSXGEN:

XLSX generator (XLSXGEN) Type choices, press Enter.

Input XML stream file . . . . . INPSTMF Output XLSX stream file . . . . OUTSTMF Add Sheets to existing WkBook . ADDTO *NO *NO, *YES Decimal positions . . . . . . . DECPOS *AUTO 0-9, *AUTO, *NOC Display zero values . . . . . . ZERODSP *YES *YES, *NO Negative numbers format . . . . NEGFMT *A *A, *B, *C Format all date cells as . . . . CVTDATE *NO *NO, *MDY, *DMY, *YMD... Null date display option . . . . NULLDATE *SAME *SAME, *BLANK, *SKIP Format all time cells as . . . . CVTTIME *NO *NO, *HMS, *ISO, ... Null time display option . . . . NULLTIME *SAME *SAME, *BLANK, *SKIP Skip blank cells . . . . . . . . SKPBLANK *NO 1-999, *NO, *YES + for more values Initial rows to be frozen . . . FROZEN 0 Number ColHdg background color . . . . HDGCOLOR *NONE Default cell colors: DFTCELLCOL Font color . . . . . . . . . . BLACK Background color . . . . . . . WHITE Cell border . . . . . . . . . . CELLBORDER *NO *NO, *YES, *COLOR, *FCOLOR.... Generate log . . . . . . . . . . LOG *NO *YES, *NO Generate XLSGEN report . . . . . XLSGENRPT *YES *YES, *NO Sizing parameters . . . . . . . SHEETSIZE Max no. of cells per workbook 2000000 10000-2000000 Max no. of sheets per workbook *AUTO *AUTO, number Run identifier . . . . . . . . . RUNID *NONE Run it in a submitted job . . . SBMJOB *NO *YES, *NO

Figure 1b - Command HSSFCGI/XLSXGEN

HSSFCGI Developer Guide

5

Page 6: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

Command parametersInput XML stream file (INPSTMF) - Specifies the XML-like XLSGEN scriptOutput XLS/XLSX stream file (OUTSTMF) - Provides the path and the name of the generated Excel spreadsheet. Extension .XLS or XLSX must be specified.Add Sheets to existing WkBook (ADDTO) - Specifies whether generated worksheets should be added to an existing workbook or to a new workbook. Enter:

*NO when the workbook does not already exist or must be re-created from scratch*YES to add the worksheet(s) to a workbook already existing.

Decimal positions (DECPOS) - Specifies the number of decimal positions to be assigned to numeric cells.If you specify a number from 0 to 9, all the numeric cells display that number of decimal positions. Thousand delimiters are displayed. If you specify *AUTO, eachnumeric cell displays the number of decimal positions specified in the input XML stream file (parameter INPSTMF). Thousand delimiters are displayed.*NOC (no commas) is the same as *AUTO, except that thousand delimiters are not displayed.Display zero values (ZERODSP) - Whether the numeric cells containing a value zero should display a zero or should display nothing. Select:

*YES (default value) to have the numeric cells containing a zero value displaying a zero*NO to have the numeric cells containing a zero value displaying nothing. This option is recommended when a large number of numeric cells may contain zerovalues, because this makes user reading much easier.

Negative numbers format (NEGFMT) - Format of the negative decimals numbers.Three options are provided. The following example is used: negative number -1234.56

*A (default value)- The negative number is represented with the minus sign in front of it and in the cell default color (usually black): -1234.56*B - The negative number is represented with the minus sign in front of it and in red color: -1234.56*C - The negative number is represented within parenthesis and in red color: (1234.56) .

Format all date cells as (CVTDATE) - Use this parameter to format all the date cells of the spreadsheet in the same way. Leave *NO, if you want each date cell in thespreadsheet be formatted according to the related FORMAT parameter specified in the XLSGEN control statements. Available conversion formats are:

*MDY (mm/dd/yy)*DMY (dd/mm/yy)*DMYY (dd/mm/yyyy)*YMD (yy/mm/dd)*YYMD (yyyy/mm/dd)*ISO (yyyy-mm-dd)*USA (mm/dd/yyyy)*EUR (dd.mm.yyyy)*JIS (yyyy-mm-dd)*JUL (yyyy-ddd)

Null date display option (NULLDATE) - This parameter tells how null date fields should by displayed in a generated Excel worksheet.A "null date" is the default value for date fields. Its value in *ISO format (YYYY-MM-DD) is 0001-01-01.The following display options are available:

*SAME - This generates an Excel cell containing exactly that date formatted according to parameter CVTDATE.*BLANK - This generates a text cell containing one blank.SKIP - This skips the generation of that date cell.

Note: Options *BLANK and SKIP result to the same display, though the cell contents are different.Format all time cells as (CVTTIME) - Use this parameter to format all the time cells of the spreadsheet in the same way. Leave *NO, if you want each time cell in thespreadsheet be formatted according to the related FORMAT parameter specified in the XLSGEN control statements. Available conversion formats are:

*HMS (hh:mm:ss)*ISO (hh.mm.ss)*USA (hh:mm AM or hh:mm PM)*EUR (hh.mm.ss)*JIS (hh:mm:ss)

Null time display option (NULLTIME) - This parameter tells how null time fields should by displayed in a generated Excel worksheet.A "null date" is the default value for date fields. Its value in *ISO format (hh.mm.ss) is 00.00.00 .The following display options are available:

*SAME - This generates an Excel cell containing exactly that time formatted according to parameter CVTTIME.*BLANK - This generates a text cell containing one blank.

HSSFCGI Developer Guide

6

Page 7: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

SKIP - This skips the generation of that date cell.Note: Options *BLANK and SKIP result to the same display, though the cell contents are different.Skip blank cells (SKPBLANK) - Use this parameter to establish whether blank text cells must not be generated.

Select *NO, to keep blank text cells as they are.Select *YES, to skip all blank text cells.Enter up to 50 numbers of columns where blank text cells should not be generated.

Initial rows to be frozen (FROZEN) - Use this parameter to establish the number of initial rows to be frozen.This parameter implements a "freeze pane".This tecnique may be used to keep steady the heading rows, while the data rows are scrolled. Very useful when handling spreadsheets with a large number of rows.Frozen rows are repeated in all print pages, thus providing a better understanding of column meanings.ColHdg background color (HDGCOLOR) - Use this parameter to select one from 47 colors (see Figure 6) to be used as background color of the text cells with type"column-header", or select *NONE to avoid using such a background color.Default cell colors (DFTCELLCOL) - Use this parameter to set the default colors (font and background) for the cells of the spreadsheet. Default cell colors do not affectcolumn header cells.Cell border (CELLBORDER) - Use this parameter to specify which cells should have borders. Enter:

*NO not to generate borders for any cells*YES to generate borders for all cells*COLOR to generate borders for cells having a background color other than WHITE or a foreground color other than BLACK*FCOLOR to generate borders for cells having a foreground color other than BLACK*BCOLOR to generate borders for cells having a background color other than WHITE.

Generate log (LOG) - If you specify LOG(*YES), log file XLSGENLOG is generated in library QTEMP. This log contains an entry for each generated worksheet cell. Incase of a failure, by displaying this log file you can easily establish which was the last spreadsheet cell generated successfully before the failure occurred.Generate XLSGEN report (XLSGENRPT) - Whether a performance report should be generated once the Excel workbook has been created. This report accounts for allthe workbook creation runs in the current job.Sizing parameters (SHEETSIZE) - This parameter is made of two elements:

1. Maximum number of cells per Excel workbook2. Maximum number of sheets per Excel workbook

When the number of cells in a workbook exceeds some POI internal limit, java memory management starts failing clearing the internal garbage collection until it enters anon-ending thread-wait status.For .xls workbooks, the maximum manageable number of cells was found to be a little over 2.3 millions.For .xlsx this number was detected to be a little over 2.0 millions.

1. The "first element" of this parameter makes sure that the number of cells upper limit for a workbook is never exceeded.As soon as it is reached, the workbook is closed and a new job is submitted to create another workbook.

2. The "second element" tells the maximum number of spreadsheets that a single workbook can hold.If you specify *AUTO for this "second element", this maximum number of spreadsheets per workbook is taken from the number of worksheets declared inthe XML-like XLSGEN input stream file specified in parameter INPSTMF.If all the requested cells can fit in a single workbook, all the declared spreadsheets are generated in a single workbook.If all the requested cells cannot fit in a single workbook, the value of this "second element" is ignored and multiple workbooks are generated.The first workbook will contain as many cells as possible for the first spreadsheet.The remaning cells will be splitted into other workbooks automatically generated from submitted batch jobs.

Run identifier (RUNID) - After creating one or more workbooks from this command, you may want to compress it or them into a zip stream file to ease their delivery (forinstance, by e-mail). If you have this need, in this parameter you should enter a case sensitive character string (30 char.s max) that would later on help you in recallingthe generated workbook(s). Example: '1st Quarter Sales' . To zip that / those workbook(s), you must run command ZIPWKB (Zip Workbooks) by specifying the sameidentifying character string in its RUNID parameter. Example: ZIPWKB RUNID('1st Quarter Sales') ... .Run in a submitted job (SBMJOB) - If you specify SBMJOB(*YES), all the Java process is executed in a batch submitted job. In this way the settings of the Java VirtualMachine of the bach job cannot conflict with the JVM settings of the current job.

Note- Commands XLSGEN and XLSXGEN provide, for any generated worksheet, a record in file QTEMP/XLSGENRPT. For the record layout, see this page.Command HSSFCGI/RPTXLSGEN reads this file and provides a printout listingall the workbooks, with information about their sheets, generated from the current job.

Usually, an initial XLSGEN is written manually and input-ed to command XLSGEN or XLSGENX to create a prototype spreadsheet.

HSSFCGI Developer Guide

7

Page 8: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

Subsequently, one may write a program that

1. generates the XLGEN script as an IFS stream file2. invokes comand XLSGEN or XLSGENX to generate an XLS or XLSX stream file from the XLGEN script3. if a CGI program, sends the XLS / XLSX stream file to the browser.

For details on such a program see the next page.

HSSFCGI Developer Guide

8

Page 9: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

1-A prototypeTake a look at this spreadsheet prototype:

Figure 2 - A prototype

The following XLSGEN script was used for generating it:

<XML> <workbook> <worksheet name="gumb" print-header="Giovanni's Used Boats" print-orientation="portrait" print-scale="110" paper-size="A4_PAPERSIZE"> <row row-height="40"> <cell hspan="2"> <data type="LargeTextC" valign="center"> GUMB - Giovanni's Used Motor Boats </data> </cell> </row> <row> <cell hspan="2"> <data type="SmallTextC" valign="center">

HSSFCGI Developer Guide

9

Page 10: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

available in April 2016 </data> </cell> </row> <row> <cell hspan="2"> </cell> </row> <row row-height="100"> <cell> <data type="picture" width="187"> /hssfcgi/images/boatM01.jpg </data> </cell> <cell> <data type="text" valign="center"> 36' Solent Spear %LF Year: 2005%LF Current Price: £ 155,000 ... Single Diesel%LF </data> </cell> </row> <row row-height="100"> <cell> <data type="picture" width="187"> /hssfcgi/images/boatM02.jpg </data> </cell> <cell> <data type="text" valign="center"> 75' Riva Venere%LF Year: 2006%LF Current Price: EUR 2,850,000 ... Twin Diesel%LF </data> </cell> </row> </worksheet> </workbook></XML>

Figure 3 - A script prototype

The following is what the interpreter (command HSSFCGI/XLSGEN or HSSFCGI/XLSXGEN) does:on tag <workbook> - starts a workbookon tag <worksheet name="gumb"> - starts a worksheet named "gumb"on tag <header>Giovanni's Used Boats</header> defines a print headeron tag <row> - starts row 1on tag <cell hspan="2"> - creates logical cell 1AB, spanning the size of two physical cells (hspan means "horizontal span")on tag <data type="LargeTextC"> - establishes a large centered font for the contents of cell 1ABthen writes the text "GUMB - Giovanni's Used Motor Boats" to cell 1ABon tag </data> ends writing to the cellon tag </cell> ends cell 1ABon tag </row> ends row 1.Row 2 is similar to row 1. The font is now a small centered one.Row 3 is similar to rows 1 and 2, but has no text.The next logical row is made of two cells, both spanning 7 physical rows (row 4 to 10). This is done by specifying a "vertical span" keyword vspan="7" at cell level. The firstcell contains a picture with an horizontal size (width) of 187 pixel, containing the image of a boat. The name of the IFS stream file containing the picture must be given in the

HSSFCGI Developer Guide

10

Page 11: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

data portion.The second cell contains a plain text, the description of a boat. Within the text you can see some %LF sequences. They are used to generate line feeds.The next logical row is similar to the previous one.

2-The XLSGEN syntaxXLSGEN is a tag language similar to XML:

A <tag> must always have a closing </tag>A tag may contain keywords. The syntax of a keyword iskeyword="value"The pair of double quotes (") is mandatory.Tag, keywords and keyword values are case insensitive.

The following table lists the keywords available for each tag.

tag keyword commentsXML Used to be consistent with XML syntax The interpreter ignores itWORKBOOK Starts a workbook A workbook is a set of worksheets.

An XLS / XLSX file can contain just one workbook.WORKSHEET Starts a worksheet

NAME="value" Name assigned to the worksheet Example:<worksheet name="2016">

PRINT-HEADER="page header text"

Worksheet print page header Example:<worksheet name="2016" print-header="Sales this year">

PRINT-ORIENTATION="PORTRAIT" or"VERTICAL" OR"LANDSCAPE" or"HORIZONTAL"

Worksheet print page orientation (♣) Example:<worksheet name="2016" print-header="Sales this year"print-orientation="landscape">

FIT-WIDTH="number of pages

Number of pages the width of the spreadsheet shouldbe compressed into. (♣)A value of 1 forces all columns to fit in the width of asingle page.

Example:<worksheet name="2016" print-header="Sales this year"print-orientation="landscape" fit-width="1">

FIT-HEIGHT="number of pages

Number of pages the heigth of the spreadsheet shouldbe compressed into. (♣)A value of 1 forces all rows to fit in the width of asingle page.

Example:<worksheet name="2016" print-header="Sales this year"print-orientation="landscape" fit-width="1" fit-height="1">

This will fit the printout in a single page.PRINT-SCALE=values from "10" to "400"

Worksheet print page scaling percentage (♣)This keyword is ignored when a FIT-... keyword isspecified.

Example:<worksheet name="2016" print-header="Sales this year"print-orientation="landscape" print-scale="120">

PAPER-SIZE="one of 33 possiblevalues"(DSPPFMHSSFCGI/PAPERSIZES)

Worksheet page size (♣) Example:<worksheet name="2016" print-header="Sales this year"print-orientation="landscape" print-scale="120"paper-size="A4_PAPERSIZE">

ROW Starts a row Examples:

HSSFCGI Developer Guide

11

Page 12: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

<row><row row-height="90"><row page-break>

ROW-HEIGHT="numberof points"

Sets the height (in points) of this row

PAGE-BREAK Generates a print page break before this row (♣)

CELL Starts a cell Examples:<cell><cell border><cell hspan="2" vspan="7"><cell hspan="2" vspan="7" overlay><cell cell-width="150">

BORDER Add borders to this single cellHSPAN="value" Number of cells that should be horizontally spanned (merged into

this cell)VSPAN="value" Number of cells that should be vertically spanned (merged into

this cell)OVERLAY To be used only when VSPAN="value greater than 1"

to allow the spanned rows to contain also other cells.See Figure 5.

CELL-WIDTH="value" Allows to size the width of a cell to a given number of pixels. Seethe example on your right. Maximum width is 889 pixels. It doesnot work when HSPAN is also specified.

DATA Defines type and format of cell dataTYPE="value" Possible values:

COLUMN-HEADER - centered small textTEXT - left aligned standard textTEXTC - centered standard textTEXTR - right aligned standard textLARGETEXT - left aligned large characters textLARGETEXTC - centered large characters textLARGETEXTR - right aligned large characters textSMALLTEXT - left aligned small characters textSMALLTEXTC - centered small characters textSMALLTEXTR - right aligned small characters textNUMBER - right aligned numberLARGENUMBER - right aligned large charactersnumberDATE - centered dateTIME - right aligned timePICTURE - imageFORMULA - Excel valid formulaDefines a formula to be computed by Excel.The expression defining the formula must be givenbetween <data ... > and </data> . Example:<data type="formula"> sum(a1:b1)</data>SKIP - no cell is generated in this column (the cellappears as containing nothing)

Note. Hyperlinks are supported as formula special cases.

Examples:<data type="largeTextC" wrap>TODAY OFFERINGS</data><data type="number">3.14</data><data type="date" format="*mdy">2019-10-27</data><data type="picture" width="187"> ... </data><data type="formula"> ... </data><data type="skip"></data>

HALIGN="value" Overrides the horizontal alignement implicit in the TYPE keyword.Possible values:

LEFTleft-aligned horizontal alignmentCENTER

Example:<data type="number" halign="left">

HSSFCGI Developer Guide

12

Page 13: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

center-aligned horizontal alignmentRIGHTright-aligned horizontal alignment

VALIGN="value" Defines the vertical alignment.Possible values:

TOPtop-aligned vertical alignmentCENTERcenter-aligned vertical alignmentBOTTOMbottom-aligned vertical alignmentJUSTIFYvertically justified vertical alignment

Example:<data type="largeTextC" valign="center">

ROTATE="value" Defines the degrees of rotation for the text in the cell. Example:<data type="Column-Header" rotate="90" halign="center">

F-COLOR="value" Defines the font color of a cell(except for <data type="column-header" ...>).The available font colors are listed in Figure 6.

Example:<data type="number" f-color="blue">

B-COLOR="value" Defines the background color of a cell.(except for <data type="column-header" ...>).The available background colors are listed in Figure 6.

Example:<data type="number" f-color="blue" b-color="gold">

NEGFMT="value" Applies only to TYPE="NUMBER" andTYPE="LARGENUMBER".Defines the format of a potential negative number.Overrides - on a single cell - the XLSGEN / XLSXGEN parameterNEGFMT.Possible values:*A example: -1,234.56*B example: -1,234.56 keyword f-color has no effect*C example: (1,234.56) keyword f-color has no effect

Example:<data type="number" negfmt="*C">

FORMAT="value" Defines the format of a date or time spreadsheet cell.Possible values:

type="date"format="..." cell format*MDY mm/dd/yy*DMY dd/mm/yy*DMYY dd/mm/yyyy*YMD yy/mm/dd*YYMD yyyy/mm/dd*ISO yyyy-mm-dd*USA mm/dd/yyyy*EUR dd.mm.yyyy*JIS yyyy-mm-dd*JUL yyyy-nnn

type="time"format="..." cell format*HMS hh:mm:ss*ISO hh.mm.ss

*USA hh:mm AM orhh:mm PM

*EUR hh.mm.ss*JIS hh:mm:ss

Examples:<data type="date" format="*MDY"> 2019.02.28</data><data type="time" format="*USA"> 15.45.23</data>

HSSFCGI Developer Guide

13

Page 14: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

WIDTH="value" Defines the width of a picture, in pixel. Example:<data type="picture" width="187">

BOLD Applies to text, date, number and formula data types. It assigns abold weight to the font.

Examples:<data type="text" bold><data type="largeTextC" bold><data type="number" bold>

UNDERLINE Applies to text, date, number and formula data types. Itunderlines the cell data.

Examples:<data type="text" underline><data type="text" bold underline>

ITALIC Applies to text, date, number and formula data types. It sets thecell data to italic types.

Examples:<data type="text" italic><data type="text" underline italic>

WRAP Applies only to the text data types. It tells whether the text stringcan be folded (wrapped).

Example:<data type="largeTextC" wrap>

HIDE Applies only to the text data types NUMBER, LARGENUMBERand FORMULA. It tells whether the numeric value of a cell mustbe hidden.

Example:<data type="number" hide>

(data value) Data value must be written between the tag <data ... > and the tag </data> .Figure 4 - Tags and keywords

Figure 5 - Effect of the OVERLAY keyword(<cell hspan="3" vspan="7" overlay>)See the sample XLSGEN stream file /hssfcgi/tmp/zzz.txt .

3-More on ...Null cellsA null cell is a cell for which the tags <datatype ...> and <data ...> are missing. Example:

HSSFCGI Developer Guide

14

Page 15: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

<cell></cell>A null cell is not generated. In other words, the cell in that position (column number, row number) of the spreadsheet is left vacant (not occupied).Character set restrictionWorkbook stream files are always generated with CCSID 819 (Latin 1 ASCII ISO/IEC 8859-1). Characters supported by this CCSID are documented on this WikipediA

page. Characters not supported by this character set ( example: the euro symbol € ) show up as character ¤ .Some special charactersCharacters < and > cannot be used within a text cell (COLUMN-HEADER, TEXT, LARGETEXT(C), SMALLTEXT(C)) and a formula cell, as these two characters are usedas delimiters.Specifying these characters whithin a text cell will cause XLSGEN to provide unpredictable results.Should you, however, need these characters within a text string, you may use their corresponding HTML entities:

&lt; (less than) instead of character <&gt; (greater than) instead of character >

Folding (wrapping) character stringsThere are two ways to fold character strings:

1. Using keyword WRAP. In this case Excel decides where the folding should take place, depending on the column width.2. Inserting line-feed sequences %LF in the text string. In this case Excel adjusts the column width on the length of the longest text segment.

These two techniques may be combined.Example:

<data type="text" wrap>Like as the waves make towards the pebbled shore,%LFSo do our minutes hasten to their end</data>

NUMBERSNumeric values are represented as follow:

<data type="number">numeric_value</data>

and must have been edited with edit code J, L, N or P.Examples of numeric_values:

editcode

englishlanguage

italianlanguage

J 1,234,567.89- 1.2334.567,89-L 1234567.89- 12334567,89-N -1,234,567.89 -1.2334.567,89P -1234567.89 -12334567,89

Note on decimal point and thousand separator characters:Decimal point and thousand separator characters (if used) must be consistent with system value QDECFMT.Inconsistent decimal points and/or thousand separator characters result to wrong value interpretation.Thousand separator characters can be used, but are not required.

DATE VALUESDate values must always be written in the ISO format YYYY-MM-DD .The desired date format for the resulting spreadsheet date cell must be specified by the keyword FORMAT=*xxx .Example:

<data type="date" format="*mdy">2009-04-23</data>

HSSFCGI Developer Guide

15

Page 16: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

TIME VALUESTime values must always be written in the ISO format hh.mm.ss .The desired time format for the resulting spreadsheet time cell must be specified by the keyword FORMAT=*xxx .Example:

<data type="time" format="*usa">21.53.37</data>

FORMULASAny formulas supported by Excel 2003 can be used. Example:

<data type="formula">AVERAGE(B34:J34)</data>

Warnings:a. If for any reason POI finds out that a formula cannot be supported, you will recreceive the following message when running XLSGEN:The call to HSSF_FORMU ended in error (C G D F)

b. For Excel formulas see this page.Besides, XLSGEN includes the following commands to generate Excel formulas:

1. VSUM - Tells Excel to compute the sum of the numbers from the preceding numeric cells in the same column.2. HSUM - Tells Excel to compute the sum of the numbers from the preceding numeric cells in the same row.3. VAVG - Tells Excel to compute the average of the numbers from the preceding numeric cells in the same column.4. HAVG - Tells Excel to compute the average of the numbers from the preceding numeric cells in the same row.5. XVSUM - Tells Excel to compute the sum of the preceding VSUM cells in the same column.

This allows to obtain a grand total from the preceding subtotals in the same column.This technique is demonstrated in the HSSFCGI CGI program XVSUMTRY.

Parameter dec-pos="n" (n = 0 to 9) can be used to establish the number of decimal positions in the result of a formula. Example:<data type="formula" dec-pos="3"> sum(b1:b6)</data>In absence on this parameter, the number of decimal positions is inherited from the previous numeric cells.HyperLinks are supported cases.The syntax to be used is as follow:<data type="formula"> hyperlink("link","text")</data>where

link can bean url link, example: http://www.easy400.neta mail link, example: mailto:[email protected] file link, example: c:\i386\blank.txt

text is the text to be linked, example:<data type="formula"> hyperlink("http://www.easy400.net","Easy400 home page")</data>

To set the width of a column containing formulas, use<cell cell-width="nnn"> (where nnn is the desired number of pixels)in at least one cell of that column (for instance, in the column header cell).

PICTURESPicture support is an uniqueness within HSSF. Pictures are copied into the workbook. In this way, they can be exported with the XLS / XLSX file itself.Warning - Only PNG and JPEG (jpg) pictures are supported.Excel shrinks or stretches your picture, as needed, to make it fit into the assigned cell(s) area.

HSSFCGI Developer Guide

16

Page 17: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

Some care should be paid in order to avoid picture distorsion. In the following textby image we mean the image file before it appears on an Excel worksheetby picture we mean the image how it appears in an Excel worksheet.

Some tips:i. Image resolution

Image sizes are measured in Pixels (dots) and image resolution is measured in Pixels per inch (PPI).XLSGEN cell width and row height are instead measured in Points (1 point = 1/72 inch).Regardless how measurements are made, it is very important that all images in a given spreadsheet column have the same resolution.

ii. Working with picture height and picture width.Picture distorsion occurs when the picture_height/picture_width has a value differen from image_height/image_width.You should therefore try to maintain in the picture the same proportion for image height and width.For instance, if a picture has a height of 1000 px and a width of 500 px, you must make sure that the cell height is twice the cell width.

Which should be cared first? The cell width or the cell height?It depends.If all the images stay in a single row, you should first establish the desired row height (all the cells in a row have the same height), then compute eachcell width in order to maintain for its picture the same proportion width/height existing in the image.If all the images stay in a single column, you should first establish the desired column width (all the cells in a column have the same width), thencompute each cell height in order to maintain for its picture the same proportion width/height existing in the image.How do I set the picture height?In the <row ...> tag specify a ROW-HEIGHT value (in points) for the desired height of all the pictures in a row. Example:<row row-height="158">How do I set the picture width?Make sure that a column containing pictures does not contain anything else. Column widths are set by the largest contents, and you need the width ofthis be the exact width you ask for.Then, in all the pictures of a given column specify the same picture width. Example:<cell> <data type="picture" width="250"> /hssfcgi/images/boatM01.jpg </data></cell>

A useful example is provided by a sample "catalog" demo available within HSSFCGI.RPG program CATALOG (HSSFCGI/QRPGLESRC mbr GOCATALOG)

generates a XLSGEN script filewhich is then processed by command XLSGEN to create a Product Catalog Excel spreadsheet.

iii. Forcing the original proportionsTo force a picture to its original dimensions, thus avoiding distorsions, you may use the keyword resize="*yes".In such a case, however, the picture may not properly fit into its cell. Example:<XML> <workbook> <worksheet name="pictures"> <row> <cell vspan="3"> <data type="picture" anchor="move" resize="*yes"> /hssfcgi/graphics/giovanni.png </data> </cell> <cell vspan="3"> <data type="picture" anchor="move" resize="*no"> /hssfcgi/graphics/SKlogo.png </data> </cell> <cell vspan="3" hspan="2">

HSSFCGI Developer Guide

17

Page 18: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

<data type="picture" anchor="move" resize="*yes"> /hssfcgi/images/boatm01.jpg </data> </cell> <cell vspan="3"> <data type="text">Description of this row %LF</data> </cell> </row> </worksheet> </workbook></XML>

iv. Picture resize and relocate permissions.You may tell how a picture should behave when the user changes its related column width, or when the user inserts a new row or column.The anchor parameter establishes the picture behavior:

<data type="picture" anchor="move">This is the default behavior: if the column size is changed, or a new column or a new row is added,the picture maintains its size and the picture row and column are relocated.<data type="picture" anchor="movesize">If the column size is changed, or a new column or a new row is added,the picture size is changed to fit the cell size and the picture row and column are relocated.<data type="picture" anchor="fixed">If the column size is changed, or a new column or a new row is added,the picture maintains its absolute position and size.

CELL COLORSThe are four different ways to assign colors (font colors and background colors) to spreasheet cells:

1. Automated fonts:Cells with <data type="Formula">HSUM</data> (horizontal sum) andcells with <data type="Formula">HAVG</data> (horizontal average)are assigned a brown font.Cells with <data type="Formula">VSUM</data> (vertical sum) andcells with <data type="Formula">VAVG</data> (vertical average)are assigned a royal blue font.Cells with <data type="Formula">formula_expression</data>are assigned an indigo font.

If - in commands XLSGEN, XLSXGEN or TABLEXLS - parameter DFTCELLCOL specifies other than (BLACK WHITE), these cells are handled as any other cell inthe spreadsheet (also they do receive the default font color and the background color specified in parameter DFTCELLCOL).

2. Column headersIn the XLSGEN language, column headers are identified from the <data type="Column-Header">.In commands XLSGEN, XLSXGEN and TABLEXLS, parameter HDGCOLOR allows to specify one out of 47 (see Figure 6) background colors to be assigned tothe column header cells. The font color is automatically assigned: black for light background colors, white for dark background colors.

3. BannerIf a spreadsheet banner is requested in command XLSTABLE, it is always given the same background and font colors as the column headers.

4. Default cell colorsIn commands XLSGEN, XLSXGEN and TABLEXLS, parameter DFTCELLCOL allows to specify a given font color and a given background color to be used for allspreahsheet cells, except the column heading ones. If default values (BLACK WHITE) are selected, no special action is taken.

5. XLSGEN language parameters f-color and b-colorThese parameters can be used in a XLSGEN script to set the font color (f-color) and the background color (b-color) of a given cell.As an example<cell> <data type="number" f-color="blue" b-color="gold">

HSSFCGI Developer Guide

18

Page 19: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

2982 </data></cell>generates the following spreadsheet cell: 2982Note that cells like this retain their colors also when default cell colors are assigned through parameter DFTCELLCOL in command XLSGEN or XLSXGEN.

Aqua Dark_red Lavender Olive_green Sea_greenBlack Dark_teal Lemon_chiffon Orange Sky_blueBlue Dark_yellow Light_blue Orchid TanBlue_grey Gold Light_cornflower_blue Pale_blue TealBlue_green Green Light_green Turquoise VioletBrown Grey_25_percent Light_orange Pink WhiteCoral Grey_40_percent Light_turquoise Plum YellowCornflower_blue Grey_50_percent Light_yellow RedDark_blue Grey_80_percent Lime RoseDark_green Indigo Maroon Royal_blue

Figure 6 - Supported cell colorsCELL STYLESCell styles are established from DATA parameters TYPE, F-COLOR, B-COLOR, BOLD and UNDERLINE.The number of supported cell styles for a workbook are 10,064:

64 of these styles are program-defined values and are related to different values of the TYPE parameter.The remaining 10,000 styles are left for user definition in the XML-like stream file input to XLSGEN.

A user-defined style can be implemented combining a pre-defined style with foreground colors, background-colors and optionally the "bold" and/or the "underline"keywords.Example of a user-defined style: <data type="largenumber" f-color="blue" b-color="gold" bold>where:

type defines a pre-defined stylef-color defines a foreground colorb-color defines a background colorbold provides a bold font weight.

When the input stream file contains more than 10,000 user-defined cell styles, a warning message appears in the joblog, and only the first 10,000 user-defined styles arehonored.

4-Large worksheets

Spreadsheets containing more than 2.3 million cells have problems to be generated. That does not depend from HSSFCGI. It looks like there are some internal POI/Java internalobject limits. Once they are exceeded, the spreadsheet creation process becomes slower and slower, until a java memory management exception is raised or a non-ending thread-waiting status is entered.In order to avoid this problem, HSSFCGI commands XLSGEN and XLSXGEN feature parameter SHEETSIZE. This parameter contains two elements: the maximum number of cellsin a workbook, and the maximum number of spreadsheets per workbook.The spreasheet generation process goes in this way:

When the maximum number of allowed cells per workbook is exceeded, orwhen the maximum number of allowed worksheets per book is exceeded,the worbook is ended and a batch job is submitted to carry on the process.This batch job generates another workbook (with a name similar to that of the previous workbook) then, if needed, submits another batch job to carry on the generation.

HSSFCGI Developer Guide

19

Page 20: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

This process goes on, through multiple submitted jobs, until all the requested cells have been generated.The program initially started by command XLSGEN or XLSXGEN stays in a wait status until the last batch job, before ending, sends an end-message to it.Sample large worksheetIt is suggested that you get familiar with large spreadsheets processing by running a sample case. You will also have the opportunity to test the XLSGEN performance on yourIBM i.

1. Run command HSSFCGI/CRTBIGXML. It creates a XLSGEN stream file, /tmp/bigXml.xml intended to generate a single spreadsheet workbook containing 3,000 rows,100 columns each, for a total of 300,000 cells.

2. Execute command HSSFCGI/XLSGEN INPSTMF('/tmp/bigXml.xml') OUTSTMF('/tmp/bigXml.xls') SHEETSIZE(30000)The job issuing the command creates a workbook (named /tmp/bigXml.xls ) containing a single 300 rows worksheet.A chain of jobs automatically submitted creates other 9 workbooks (named /tmp/bigXml.xls and /tmp/bigXml_NBR1.xls to /tmp/bigXml_NBR10.xls), each onecontaining a single 300 rows worksheet.

We have run this test on an IBM Power System Model M25 and the test took about 13 minutes.The resulting performance figures are:

22,388 cells created in a minute373 cells created in a second.

5-Command ZIPWKB

You may use this command to zip (compress) the Excel workbooks generated from one of the HSSFCGI commands (XLSGEN, XLSXGEN, XLSGEN2, XLSXGEN2, TABLEXLS andTABLEXLS2) provided that:

1. You have installed the ZIP utility provided by site http://www.easy400.net2. In the HSSFCGI command used to generate one or more workbooks, in parameter RUNID you have specified a unique character string identifying the generated workbooks.

Zip Excel workbooks (ZIPWKB) Type choices, press Enter. Run identifier . . . . . . . . . RUNID Zip stream file to be created . ZIPFILE Display result . . . . . . . . . DSP *NO *YES, *NO

Figure 7 - Command HSSFCGI/ZIPWKBRun identifier (RUNID) - This must be exactly the same (case sensitive) character string that you have specified in parameter RUNID of the command (XLSGEN, XLSXGEN,XLSGEN2, XLSXGEN2, TABLEXLS or TABLEXLS2) to create the Excel workbooks that you now want to zip.Note: If you do not remember what this string was, you can find it out by browsing file HSSFCGIDTA/RUNWKB.Zip stream file to be created (ZIPFILE) - Path and name of the IFS stream file where you want the Excel workbooks be zipped.Note: If that stream file already exists, your user profile must have full authorities over it, as it will be replaced.Display result (DSP) - Whether you want the compression results be displayed (interactive jobs only).

6-Error recording

When an XLSGEN or XLSXGEN process is interrupted by an error condition, understanding what happened is not a simple job. It may require to investigate joblog and dumps, theXLSGEN script and the program source code.

There are three type of exceptions:Program errorsJava exceptions due to wrong tags in the XLSGEN scriptJava exceptions due to memory problems.

XLGEN and XLSGEN program code is clean enough and you should not expect any program errors from it.

HSSFCGI Developer Guide

20

Page 21: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

Java exceptions may be caused by incorrect XLSGEN tags, such as a formula that Excel would not accept.Java exceptions due to memory are caused by attempts to generate a too large workbook.

In order to provide the user with a quick problem determination tool, both XLGEN and XLSGEN have been added an error routine that records some basic error information on adatabase file.To display the error collection you just run command hssfcgi/dsperrs.

1. You receive a first screen listing all the errors collected in a time descending sequence (the most recent error is listed first). For each error you are displayed:a. The time when the error occurredb. The name of the workbook being created (parameter OUTSTMF)c. The name of the last worksheet saved in the workbookd. The total number of worksheet rows in the workbooke. The name of the worksheet being processed when the error occurredf. The number of the worksheet row being written when the error occurred (this is a row sequence number within the worksheet)g. The number of row-cell being written when the error occurred (this is a cell sequence number within the worksheet row)h. The absolute number of the row being written when the error occurred (this is a row sequence number within the workbook)i. The absolute number of the cell being written when the error occurred (this is a cell sequence number within the workbook)

- When items 1f and 1g are different from zero, most likely the error occurred while trying to write that specific cell. Either the cell contains an unsupported value, or a memoryconstraint did not allow the cell to be added.- When items 1f and 1g are both zero, most likely the error occurred while trying to add the worksheet to the workbook, and that is usually a memory problem (the workbook istoo big).

2. If you select the error with a 9, you are displayed a second screen telling you more:a. The procedure, RPG program and RPG module names. XLSGEN_1 and XLSGEN_2 are the programs run by command XLSGEN. XLSXGEN is the program run by

command XLSXGEN.b. The number of the source statement in the RPG program module that was tried to be executed when the error occurred. This piece of information is generally for the

developer, unless you are willing to check the source code.c. The RPG IV routine that was in execution when the error occurred. This is generally the name of the Scott Klements HSSFR4 subprocedure invoked by the source

statement 2b (Scott Klements subprocedures are the ones interfacing Java). For instance, the name write refers to a subprocedure which writes the spreadsheet intothe workbook.The names hssf_text and ss_text refer to subprocedures that write a text cell into a spreadsheet row.The names hssf_num and ss_num refer to subprocedures that write a numeric cell into a spreadsheet row.The names hssf_date and ss_date refer to subprocedures that write a date cell into a spreadsheet row.The names hssf_formula and ss_formula refer to subprocedures that write a formula cell into a spreadsheet row.

7-Creating an XLS / XLSX stream file from a programThat is documented in the next page.

Footnotes(♣) Unluckily, keywords PRINT-ORIENTATION, FIT-WIDTH, FIT-HEIGHT, PRINT-SCALE, PAPER-SIZE and BREAK work only for spreadsheets with extension XLS (MS Office

2003), they do not work on spreadsheets with extension XLSX (MS Office 2007).(♣♣) Keyword SETRTL (Set display from right to left) requires at least V5R4 (POI 3.6) and works only for spreasheets with extension XLS (MS Office 2003).

HSSFCGI Developer Guide

21

Page 22: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

Last modified on 05/11/2019 14:22:37

HSSFCGICreate a spreadsheet from a program

Simple programmingFacilities for CGIDEV2-based programsWorking with multiple Java frameworks

1-Simple programmingTo write a program that generates a spreadsheet you do not have to know Java, nor you have to know ILE-RPG or the CGI techniques supported by CGIDEV2.

The only thing you have to do is to use your favorite programming language to build on the IBM i a program able to generate an IFS stream file containing an XLSGENscript.Once this is done, use command

xlsgen to generate the XLS spreadsheet as an IFS stream file, ORxlsxgen to generate the XLSX spreadsheet as an IFS stream file

and have it executed from EXCEL.

If you were able to do this manually, as a programmer you would love to have it done from a program.

2-Facilities for CGIDEV2-based programsOf course, if you are an ILE-RPG programmer and expecially if you are trained to use CGIDEV2, then you will start smiling, because the next part of this page is foryou.

In HSSFCGI/QRPGLESRC there are three sample CGI programs providing teaching demos for this job:

The first sample program, named FAMACC (Family Accounting), reads a family-accounting data basefile to generate a single sheet workbook.Though pretty simple, it features HSUM, VSUM and VAVG formulas, plus a true Excel formula.

Press this link to have it generating a spreadsheet and sending it to your browserPress this link to display the XLSGEN script generated by this programPress this link to display the source of this program.

1.

The second sample program, named GUB (Giovanni's Used Boats), reads a boats-for-sale database file to come up with a two sheets workbook.The fun of it is that it features cells including pictures.

Press this link to have it generating a spreadsheet and sending it to your browserPress this link to display the printout from this spreadsheetPress this link to display the XLSGEN script generated by this programPress this link to display the source of this program.

2.

The third sample program, named XVSUMYTRY (XVSUM example), reads a sales summary database file and shows how to use XLGEN formulas VSUM andXVSUM to create subtotals and grand totals.

Press this link to have it generating a spreadsheet and sending it to your browserPress this link to display the XLSGEN script generated by this programPress this link to display the source of this program.

3.

The fourth sample program, named GOCATALOG (Products catalog), reads a product catalog database file to come up with a product catalog worksheet.In this program, each picture height is individually computed.

Press this link to have it generating a spreadsheet and sending it to your browserPress this link to display the XLSGEN script generated by this programPress this link to display the source of this program.

4.

Write your program following one or the other of the example programs:Use subprocedure GetHtmlIfs or GetHtmlIfsMult to load the external script /hssfcgi/html/XLSGEN_template.txt. Always use this script as a skeleton foryour XLSGEN script.

1.

Use subprocedures UpdHtmlvar and WrtSection to create the XLSGEN script in the output buffer.2. Use subprocedure WrtHtmlToStmf to create the XLSGEN-script IFS stream file.3. Use subprocedure ClrHtmlBuffer to clear the output buffer.4. Run command hssfcgi/xlsgen to interpret the XLSGEN-script and to generate the XLS or XLSX spreadsheet stream file.5. If running under HTTP, use subprocedure SndStmfToBrowser to send the XLS or XLSX spreadsheet stream file to the browser. SubprocedureSndStmfToBrowser is from service program hssfcgi/hssfcgix.

6.

Command WEBXLSGENIn writing you CGI program you may also take advantage of command HSSFCGI/WEBXLSGEN. This command is very similar to commands XLSGEN and XLSXGEN,but provides further functions:

Creates the XLS or XLSX stream file from the XML-like XLSGEN stream file (as commmands XLSGEN or XLSXGEN would do). Then, if running in a HTTPinstance, ...

a.

Sends the XLS or XLSX stream file to the browserb. Submits a job to delete the XLS/XLSX stream file after 5 minutes.(Note that it is a program responsibility to decide to delete the XML-like XLSGEN stream file.)

c.

Subprocedure GetColName()In your program creating the XLSGEN XML-like script, you may have the need specify in a formula some cell names in the way it is done by Excel. As an example, cellname AK82 would be the cell in column number 37 and row 82.Usually your program has full control on the column and row numbers. So, at a given point of your program you know that you are on row 82 and column 37. However,how do you convert 37 to the "AK" Excel notation?You do that with subprocedure GetColName(), example:

colName=GetColName(37) .See the sample program in HSSFCGI/QRPGLESRC member GETCOLNAME.

HSSFCGI Developer Guide

22

perotti
Highlight
Page 23: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

3-Working with multiple Java frameworksJava environment variables CLASSPATH, QIBM_RPG_JAVA_PROPERTIES and JAVA_HOME must be set in a job before the Java Virtual Machine (JVM) is started.Trying to replace them after JVM has started, is no use.

This may cause problems when your program tries two use more than one Java framework.

As an example, let us assume that your programsets up the Java environment to use Scott Klement's JDBC framework to create a tablecreates the tabletries to run command HSSFCGI/TABLEXLS to generate a spreadsheet from that table.

Though command HSSFCGI/TABLEXLS tries to set up the Java environment by replacing the Java environment variables, this has no effect, as the JVM has alreadystarted, and command TABLEXLS ... bumps out because unable to retrieve the needed Java classes.

There are some ways to solve this problem:

Setup a complete Java environment before starting the JVM.This approach requires that the Java environment variables are setup for all the Java frameworks used by the program before using the first framework. Thiscould be not so easy to be coded, as the environment variables needed by the HSSFCGI commands are hidden in a service program. However, your programmay use subprocedure Get_HSSFCGI_Java() to retrieve these environment variables. Source member SAMPLEJPGM in HSSFCGI/QRPGLESRC providesthe example of how to perform Java environment initialisation when using two frameworks, JDBC and HSSFCGI.Note- It should however be noted that once your program has started, the Java setup for the job can no longer be changed and that may prevent using otherJava-based programs in the same job.

A.

Run command HSSFCGI/JVMSTARTUP as soon as a job is started or before executing any application using the JVM.This command sets up the JVM environment for HSSFCGI and XLPARSE2 and optionally extends the classpath through a string provided in a parameter ofthis command.This makes sure that HSSFCGI and XLPARSE2 java code can run, whatever other mix of java programs is going to be executed.

B.

Use SBMJOB(*YES) on HSSFCGI commands XLSGEN, XLSXGEN or TABLEXLS.If you specify parameter SBMJOB(*YES) on HSSFCGI commands XLSGEN, XLSXGEN or TABLEXLS, the Java part of the related program is executed in asubmitted batch job. This is done in a completely seamless way. By doing this, you cannot have conflicts between HSSFCGI Java setup and the Java setup ofyour job.Note- That does not completely solve the problem of having a JVM been started in your job, unless you provide a way to run also the other Java frameworks insubmitted jobs synchronized with your main job.

C.

HSSFCGI Developer Guide

23

Page 24: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

Last modified on 09/22/2019 00:20:01

HSSFCGITABLEXLS: Create Excel workbooks from IBMi database files

In the previous pages we have describedA special XML-like script language that allows command XLSGEN to generate an XLS orXLSX Excel workbookHow you can produce such an XML-like script from a program.

As the next step, what about a general program that would1. read whatever database files2. generate from them an XLSGEN XML-like script3. invoke command XLSGEN or XLSXGEN to create an Excel workbook containing one or

more spreadsheets ?

We have developed such a program for you in library HSSFCGI, and you can run it throughcommand TABLEXLS.

Is TABLEXLS not enough for your needs?To create Excel spreadsheets, command TABLEXLSgenerates an intermediate XLSGEN script (see the streamfile specified in parameter TOXML), which is then processedby command XLSGEN. That generated XLSGEN script isbased on a small subset of the XLSGEN keywords, drivenby some of the parameters in command TABLEXLS.

Should you need more spreadsheet features than providedby commnd TABLEXLS, you have to write your XLSGENscript and process it with command XLSGEN.We suggest that - for learning purposes - you first look atsome intermediate XLSGEN script generated by aTABLEXLS of yours by specifying parameterPRINTXML(*YES), and compare those script statementswith the XLSGEN keywords table.More examples on using XLSGEN scripts are provided in thesection Program development.

Generate an XLS/XLSX from db files (TABLEXLS) Type choices, press Enter.

From database files . . . . . . FROMFILE Name Library . . . . . . . . . . . *LIBL Name, *LIBL + for more values

*LIBL From members . . . . . . . . . . FROMMBR *ALL Name, generic*, *FIRST, *ALL + for more values RecordFormat number to process . RCDFMTNBR 1 1-999 To .xml stream file . . . . . . TOXML *AUTO

HSSFCGI Developer Guide

24

perotti
Highlight
Page 25: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

To .xls or .xlsx stream file . . TOXLS Include also existing XML stmf: INCLUDEXML XML file to be included . . . *NONE before spreadsheet body row . *START Number, *START, *END Edit the .xml stream file . . . EDITXML *NO *YES, *NO Print the .xml stream file . . . PRINTXML *NO *YES, *NO Add Sheets to existing WkBook . ADDTO *NO *NO, *YES Sheet names . . . . . . . . . . SHEETNAME *MBRNAME Name, *MBRNAME Display sheets right to left . . SETRTL *NO *YES, *NO Banner identifier . . . . . . . BANNERID *NONE 0-99999, *NONE Alternate Column Headings stmf ALTCOLHDG Column headings option . . . . . COLHDGOPT 1 0, 1, 2, 3 ColHdg rotation degrees . . . . HDGROTATE 0 0, 90, -90 ColHdg background color . . . . HDGCOLOR *NONE Default cell colors: DFTCELLCOL Font color . . . . . . . . . . BLACK Background color . . . . . . . WHITE Cell border . . . . . . . . . . CELLBORDER *NO *NO, *YES, *COLOR, *FCOLOR... Frozen pane: FROZEN no. of frozen initial rows . . 1 0-99999 no. of frozen initial columns 0 0-99999 Display zero values . . . . . . ZERODSP *YES *YES, *NO Decimal positions . . . . . . . DECPOS *AUTO 0-9, *AUTO, *NOC Negative numbers format . . . . NEGFMT *A *A, *B, *C Convert all date fields to . . . CVTDATE *ISO *ISO, *USA, *EUR, ... Convert all time fields to . . . CVTTIME *ISO *ISO, *USA, *EUR, ... Skip blank cells . . . . . . . . SKPBLANK *NO 1-999, *NO, *YES + for more values Skip fields by field test: SKPFLDS Field name . . . . . . . . . . Character value Relational operator . . . . . *EQ, *NE, *LT, *GT Comparison value . . . . . . . + for more values Ignore fields . . . . . . . . . IGNFLDS *NONE Name, *NONE + for more values HyperLink fields: LINKFLDS Link field . . . . . . . . . . Name Text field . . . . . . . . . . Name + for more values Display pictures . . . . . . . . PICTURES *NO *YES, *NO VSPAN for picture cells . . . . VSPAN 7 Number Pictures width in pixel . . . . WIDTH 187 Number Paper size . . . . . . . . . . . PAPERSIZE A4_PAPERSIZE Print-orientation . . . . . . . PRTORIENT *PORTRAIT *PORTRAIT, *LANDSCAPE Header: PRTHDR 'Print header' . . . . . . . . *MBRTXT Show also on worksheet . . . . *YES *YES, *NO

HSSFCGI Developer Guide

25

Page 26: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

Generate log . . . . . . . . . . LOG *NO *YES, *NO Generate XLSGEN report . . . . . XLSGENRPT *NO *YES, *NO Download Excel stmf if CGI job . DOWNLOAD *YES *YES, *NO Run XLSGEN in a submitted job . SBMJOB *NO *YES, *NO Sizing parameters . . . . . . . SHEETSIZE Max no. of cells per workbook 2000000 10000-2000000 Max bo. of sheets per workbook *AUTO *AUTO, number Run identifier . . . . . . . . . RUNID *NONE Print-fit: PRTFIT Sheet fit-width (nbr. pages) 0 0-99999 Sheet fit-height (nbr. pages) 0 0-99999 Print-scale . . . . . . . . . . PRTSCALE 100 10-400

Figure 5 - Command HSSFCGI/TABLEXLS

This command generates - from one or more database files - an Excel workbook on the IFS. The workbook is either type XLS or XLSX depending on the extensionspecified in the TOXLS stream file name. The generation process goes through three main steps:

1. For each database file a so-called AD-HOC ILE-RPG program is generated in library HSSFCGIDTA(This is why to run command TABLEXLS on an IBMi box you need the ILE-RPG compiler).These programs are used to read the database files. An XLSGEN script (an XML-like script, input to command XLSGEN or XLSXGEN) is then generatedwhile reading the database files.

2. If you specify TOXLS(*NONE), the process stops here. You can then display, edit or update with some program of yours the XML-like XLSGEN script, thatyou will later on process with command XLSGEN or XLSXGEN under your control.

3. If you specify for TOXLS a stream file name, then the TABLEXLS program goes on and processes the XML-like XLSGEN script through command XLSGENor command XLSXGEN (according to the extension of the TOXLS stream file), thus generating an XLS or XLSX stream file ready for Excel.

Note on date fieldsOur utility cannot tell whether a database record field contains a date, unless the field definition supports the DDS keyword DATFMT (date format). If the DATFMTkeyword is found at field level, then we are sure that the field contains a date, and the value of the DATFMT keyword tells us what is the date format that shouldbe displayed.DDS data type L is used to define date fields on physical files, and these type of fields support the DATFMT keyword. Also logical file signed and packed fieldsbased on physical date fields should support the DATFMT keyword, according to the IBM System i DDS Manual.Only the database fields supporting the DATFMT keyword are date fields for the TABLEXLS utility. They are converted to spreadsheet date cells and are editedaccording to their DATFMT values.Other fields containing date values, such as plain numeric or character fields, are not detected as date fields by the TABLEXLS utility, and are converted tospreadsheet numeric or text cells without any date formatting.

Should you need to have some character or numeric fields be converted to spreadsheet date cells, you must use parameter TOXLS(*NONE) to generate just theXML-like XLSGEN script, change the <data type="..."> declarations to <data type="date" format="..."> declarations, then process the XML-like script withcommand XLSGEN or XLSXGEN.

Command parameters:From database files (FROMFILE) - Qualified names of one or more (up to 50) database files that will be used to generate the XLS or XLSX Excel workbook.From members (FROMMBR) - Up to 50 database file members to be processed. Each member will be a separate worksheet in the workbook. Allowedsingle values:

*FIRST - the first or only database file member*ALL - all the database file members.

NOTE- If a list of members is provided, but none of such members is found on a given database file, member *FIRST is assumed for that database file.

HSSFCGI Developer Guide

26

Page 27: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

RecordFormat number to process (RCDFMTNBR) - The columns of an Excel spreadsheet can just map the layout of a single record format. IBM i physicalfiles and most of IBM i logical files are single formatted. However some logical files may be multiple formatted.Parameter RCDFMTNBR specifies - for all the database files listed in parameter FROMFILE - the sequence number of the record format that is processedfor spreadsheet generation. You must specify RCDFMTNBR(1) to select the first record format, RCDFMTNBR(2) to select the second record format, and soon.

When a single database file is specified in parameter FROMFILE, parameter RCDFMTNBR may specify value 1 or a value higher than 1.On the other side, when more than one database file is specified in parameter FROMFILE, parameter RCDFMTNBR must mandatorily specify value1.

In other words, this parameters helps in processing a record format other than the first one, provided that a single input database file is specified inparameter FROMFILE.To .xml stream file (TOXML) - This is the name of the XLSGEN script (an XML-like) stream file that will be generated, then processed.

If you specify *AUTO, the name of this stream file will be assigned by the program, and the stream file will be deleted at the end of the process.If you specify a stream file name of your choice, the stream file will not be deleted at the end of the process. This option allows you to manuallymodify the XLSGEN script and to use it as input to an XLSGEN command under your control. In this way you may customize the XLS/XLSXspreadsheet according to your needs.

To .xls or .xlsx stream file (TOXLS) - This is the name of the XLS stream file (the workbook) that will be generated by the program through the use of anXLSGEN command.An estension .xls or .xlsx is required.

Note: You may specify *NONE instead of a stream file name. If you do so, command XLSGEN/XLSXGEN is not invoked, and the XLS/XLSXstream file is not generated. In this way you may edit or process the generated XML-like stream file, update it to better fit your needs andprocess it later on with command XLSGEN or XLSXGEN.

Include also existing XML stmf (INCLUDEXML) - This parameter may be used to include - in the generated XLSGEN stream file specified in parameterTOXML - all the statements of another existing XLSGEN stream file.This parameter has two elements:

1. The name of the XLSGEN (XML-like) stream file to be included2. The number of the generated XLSGEN row before which the inclusion will take place. Special values are:

*START or 1 to include this stream file "before" the first generated <row> of a spreadsheet.*END to include this stream file "after" the last generated <row> of a spreadsheet.

Note 1: This parameter may be used to include a banner or / and a trailer to spreadsheets generated from command TABLEXLS.Note 2: The XLSGEN stream files to be used for inclusion can be created manually, from programs or using command GETXMLROWS to copy rows froman already existing XLSGEN stream file.Note 3: More information and examples are available at page TABLEXLS includexml.Edit the .xml stream file (EDITXML) - If you specified TOXLS(*NONE), and you are running an interactive job, you may ask to edit the XML-like stream fileas soon as it is generated.Print the .xml stream file (PRINTXML) - Specify PRINTXML(*YES) to print the intermediate XML-like XLSGEN script that will be used by XLSGEN togenerate the Excel workbook.The spooled filed is named XMLPRINTF and contains two parts:

The first part (Phase 1) lists the XML-like XLSGEN script created by program TABLEXLS through one of its automatically generated AD-HOCprograms.The second part (Phase 2) lists the XML-like XLSGEN script converted to canonical format, as expected by program XLSGEN.

Note - PRINTXML(*YES) may generate huge spool files. It should be used only for investigating the intermediate XLSGEN language used to create theExcel workbook.Add Sheets to existing WkBook (ADDTO) - This parameter specifies whether generated worksheets should be added to an existing workbook or to a newworkbook. Enter:

*NO when the workbook does not already exist or must be re-created from scratch*YES to add the worksheet(s) to a workbook already existing.

Sheet names (SHEETNAME) - Name to be assigned to the generated worksheets. You have two choices:a. Leave the default value *MBRNAME. By doing so, each sheet is assigned the name of the related database a. file member.

HSSFCGI Developer Guide

27

Page 28: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

b. Enter a name of up to 8 characters. By doing so, each sheet is assigned this name followed by a sequence number.Display sheets right to left (SETRTL) - Whether the worksheets should be displayed from right to left instead of left to right.Note: This parameter works only from release V5R4 on and if the extension of the workbook is xls .Banner identifier (BANNERID) - Numeric identifier of a banner to be added at the beginning of each generated worksheet.When no banner is desired, BANNERDID(*NONE) or BANNERID(0) must be specified.Banners are defined through command HSSFCGI/WRKBAN .A banner is a strip of spreadsheet cells, that takes all the columns in some initial rows and is made of the following three elements:

1. A picture anchored in the first columns of the spreadsheet2. A title sitting in the remaining columns of the spreadsheet3. A subtitle below the title, in the remaining columns of the spreadsheet.

These elements are called "banner properties".For detail information and examples of using TABLEXLS banners, see this page.Alternate Column Headings stmf (ALTCOLHDG) - As a default, a single spreadsheet column header row would be generated from the database file fielddescriptions.An alternate column headings structure, made of one or more spreadsheet rows, defined by the user, can be used only for the first database file. Thisalternate column headings structure

must be defined on a stream file using the XLSGEN tags <row>, <cell>, <data>, </data>, </cell> and </row>.Note: Of course, when an ALTCOLHDG stream file is specified, parameter HDGCOLOR (Column headings background color) no longer applies. To obtainforeground and background colors, XLSGEN keywords f-color and b-color must be specified in the tags of the stream file (XLSGEN script) specified in thisparameter ALTCOLHDG.For a detail example about using this parameter, see this page.Column headings option (COLHDGOPT) - Use this option to specify the way the column headings of an Excel spreadsheet are filled in.Select one of the following:

0 - Column headings are not generated.1 - Database field column headings are used if available. Otherwise field text descriptions are used if available. If not, field names are used.2 - Database field text descriptions are used if available. Otherwise field column headings are used if available. If not, field names are used.3 - Field names are used.

Note. The generated column headers are all contained within the first row.ColHdg rotation degrees (HDGROTATE) - Number of degrees the column-header texts will be rotated. Select one of the following:

0 to keep them horizontal90 to rotate them vertically, text reading bottom-top-90 to rotate them vertically, text reading top-bottom

ColHdg background color (HDGCOLOR) - Select one of 47 colors to be used as background color for the cells in the first row of the generated spreadsheet(Column Headers), or select *NONE to avoid using a background color.The available colors are listed here.Column Header cells are always assigned borders, regardless of what is specified in parameter CELLBORDER (see below).Default cell colors (DFTCELLCOL) - These are the default cell colors to be assigned to all spreadsheet cells. There are two default cell colors:

The first color is the font color for the text to be written in a cell.The second color is the background color of the cell.

Each color can be chosen from a list of 47 colors.The available colors are listed here.Cell border (CELLBORDER) - Specifies which cells should be given borders. Enter:

*NO not to generate borders for any cells*YES to generate borders for all cells*COLOR to generate borders for cells having a background color other than WHITE or a foreground color other than BLACK*FCOLOR to generate borders for cells having a foreground color other than BLACK*BCOLOR to generate borders for cells having a background color other than WHITE.

Freeze pane columns and rows (FROZEN) - This parameter allows to freeze some initial rows and/or columns of the generated worksheet(s).

HSSFCGI Developer Guide

28

Page 29: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

Frozen intial rows and/or columns keep steady while you scroll a spreadsheet.This parameter is made of two elements:

1. Number of frozen initial rows.Frozen rows are repeated on all print pages.Note. To freeze just the column header row(s) when COLHDGOPT not zero or when ALTCOLHDG specified, ask just 1 initial row to be frozen.

2. Number of frozen initial colums.Display zero values (ZERODSP) - Whether the numeric cells containing a value zero should display a zero or should display nothing. Select:

*YES (default value) to have the numeric cells containing a zero value displaying a zero*NO to have the numeric cells containing a zero value displaying nothing. This option is recommended when a large number of numeric cells maycontain zero values, because this makes user reading much easier.

Decimal positions (DECPOS) - Number of decimal positions for the numeric cells of the spreadsheet.If you specify a number from 0 to 9, all the numeric cells display that number of decimal positions. Thousand delimiters are displayed.If you specify *AUTO, each numeric cell displays the number of decimal positions specified in the input XML stream file (parameter INPSTMF).Thousand delimiters are displayed.*NOC (no commas) is the same as *AUTO, except that thousand delimiters are not displayed.

Negative numbers format (NEGFMT) - Format of the negative decimals numbers.Three options are provided. The following example is used: negative number -1234.56

*A (default value)- The negative number is represented with the minus sign in front of it and in the cell default color (usually black): -1234.56*B - The negative number is represented with the minus sign in front of it and in red color: -1234.56*C - The negative number is represented within parenthesis and in red color: (1234.56) .

Convert date fields to (CVTDATE) - Format to be used in representing EXCEL date values. Select one of the following:*ISO (yyyy-mm-dd)*USA (mm/dd/yyyy)*EUR (dd.mm.yyyy)*JIS (yyyy-mm-dd)*YYMD (yyyy/mm/dd)

Convert time fields to (CVTTIME) - Format to be used in representing EXCEL time values. Select one of the following:*ISO (hh.mm.ss)*USA (hh:mm AM or hh:mm PM)*EUR (hh.mm.ss)*JIS (hh:mm:ss)

Skip blank cells (SKPBLANK) - Use this parameter to establish whether blank text cells must not be generated.Select *NO, to keep blank text cells as they are.Select *YES, to skip all blank text cells.Enter up to 50 numbers of columns where blank text cells should not be generated.

Skip fields by field test (SKPFLDS) - Use this parameter to define if some record format fields should not generate a cell - leaving a hole in the appropriatespreadsheet column - when meeting given conditions.Up to 50 record format different fields can be defined, provided that their data types are one of the following:A (character), 5 (binary character), L (date), T (Time), Z (timestamp), B (binary), F (float), P(packed), S (zoned).For each such field three elements must be defined:

Field name - The field name as defined in the data base file record format. It must be within 'quotes' if containing special characters. Example:'BIRTH_DATE')Relational operator - One of the following operators:*EQ (equal to), *NE (not equal to), *LT (lower than), *GT (greater than).Comparison value - The value to be compared to the field value.Character values must be within 'quotes'. Numeric values, if including decimal point and/or thousands delimiters, must also stay within 'quotes'.

Note. Date comparison values must always be in ISO format yyyy-mm-dd even when the related field is defined with a different format(examples: *MDY, *DMY, *DMYY, *YMD, *YYMD, *USA, *EUR, *JIS, *JUL).

HSSFCGI Developer Guide

29

Page 30: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

Example: SKPFLDS(('BIRTH_DATE' *LT '1980-01-01') (BIRTHCNTRY *NE US))Ignore fields (IGNFLDS) - You may specify up to 50 field names that are to be excluded from the generated Excel spreadsheet.Hyperlink fields (LINKFLDS) - You may specify up to 50 pairs of field names to be used for creating hyperlink spreadsheet cells.Each pair of field names is made up of

1. The name of a character field containing one of the following link types:an URL link, example: http://www.easy400.neta MAIL link, example: mailto:[email protected] FILE link, example: c:\mydir\mydoc.doc

2. The name of a character field containing a description 2. of the link.You may run a test of this feature by entering commandTABLEXLS FROMFILE(hssfcgi/hyper) TOXLS('/tmp/hyper.xls') PRTHDR(*MBRTXT) LINKFLDS((itmlnk itmdes))Display pictures (PICTURES) - If the database file contains character fields specifying the names of .PNG or .JPG pictures(example: /mydir/mypicture1.jpg), you may ask to have these pictures displayed in the spreadsheet instead of just showing their names.Select:

*YES to display the pictures instead of their names, or*NO to display just the stream file names of the pictures, as for any other character field.

Note- For some information about how pictures are specified in a XLSGEN XML-like script, see this page.VSPAN for picture cells (VSPAN) - This parameter (vertical span) is required if PICTURES(*YES) is specified.This parameter is used to specify the height of the pictures and is expressed as the number of spreadsheet rows to be spanned for a picture cell.The default value is 7 (picture cells are given a height corresponding to 7 spreadsheet rows).Pictures width in pixel (WIDTH) - This parameter is required if PICTURES(*YES) is specified.This parameter is used to specify the width in pixel of the pictures cells.Please note that a picture width is always expanded to the cell width, which is assessed by the largest cell in the same spreadsheet column.Paper size (PAPERSIZE) - 33 different paper sizes are available. Use the command prompt or run command DSPPFM HSSFCGI/PAPERSIZES to displaythem.Note: This parameter works only if the extension of the workbook is xls .Print-orientation (PRTORIENT) - Select

*PORTRAIT to print the worksheet in Portrait mode (no page rotation)*LANDSCAPE to print the worksheet in Landscape mode (90 degree rotated page).

Note: This parameter works only if the extension of the workbook is xls .Header (HEADER) - This parameter is used to specify the print header. Two elements are needed:

1. Print header - The allowed values are:*DFT - The print header displays the qualified database file name*FILETXT - The print header displays the database file text description*MBRTXT - The print header displays the member text descriptiona text description of your own that will apply to all members.

2. Show also on the worksheet - Select*YES, to display the print header in the first row of the worksheets. Note that *YES is disregarded when *DFT is selected for the print header.*NO, not to display the print header on the worksheets.

Generate log (LOG) - If you specify LOG(*YES), log file XLSGENLOG is generated in library QTEMP. This log contains an entry for each generatedworksheet cell. In case of a failure, by displaying this log file you can easily establish which was the last spreadsheet cell generated successfully before thefailure occurred.Download Excel stmf if CGI job (DOWNLOAD) - When command TABLEXLS is executed from a job in subsystem QHTTPSVR (a CGI job), this optionallows to download to the client browser the generated Excel stream file. Of course, if this is done, no other response from the CGI program should be sentto the browser.If command TABLEXLS is issued from a CGI program:

Leave *YES to have the CGI program sending out the Excel stream fileType *NO to avoid downloading the Excel stream file and to have the CGI program providing its own response to the browser.

HSSFCGI Developer Guide

30

Page 31: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

Generate XLSGEN report (XLSGENRPT) - Whether a performance report should be generated once the Excel workbook has been created.This report accounts for all the workbook creation runs in the current job.Run XLSGEN in a submitted job (SBMJOB) - If you specify SBMJOB(*YES), all the XLSGEN Java process is executed in a batch submitted job. In this waythe settings of the Java Virtual Machine of the bach job cannot conflict with the JVM settings of the current job.Sizing parameters (SHEETSIZE) - This parameter is made of two elements:

1. Maximum number of cells per Excel workbook2. Maximum number of sheets per Excel workbook

When the number of cells in a workbook exceeds some POI internal limit, java memory management starts failing clearing the internal garbage collectionuntil it enters a non-ending thread-wait status.For .xls workbooks, the maximum manageable number of cells was found to be a little over 2.3 millions.For .xlsx this number was detected to be a little over 2.0 millions.

1. The "first element" of this parameter makes sure that the number of cells upper limit for a workbook is never exceeded.As soon as it is reached, the workbook is closed and a new job is submitted to create another workbook.

2. The "second element" tells the maximum number of spreadsheets that a single workbook can hold.If you specify *AUTO for this "second element", this maximum number of spreadsheets per workbook is taken from the number of worksheetsdeclared in the XML-like XLSGEN input stream file specified in parameter TOXML.If all the requested cells can fit in a single workbook, all the declared spreadsheets are generated in a single workbook.If all the requested cells cannot fit in a single workbook, the value of this "second element" is ignored and multiple workbooks are generated.The first workbook will contain as many cells as possible for the first spreadsheet.The remaning cells will be splitted into other workbooks automatically generated from submitted batch jobs.

Run identifier (RUNID) - After creating one or more workbooks from this command, you may want to compress it or them into a zip stream file to make theirdelivery easier (for instance, by e-mail).If you have this need, in this parameter you should enter a case sensitive character string (30 char.s max) that would later on help you in recalling thegenerated workbook(s). Example: '1st Quarter Sales' .To zip that / those workbook(s), you must run command ZIPWKB (Zip Excel workbooks) by specifying the same identifying character string in its RUNIDparameter.Example: ZIPWKB RUNID('1st Quarter Sales') ... .Run in a submitted job (SBMJOB) - If you specify SBMJOB(*YES), all the Java process is executed in a batch submitted job. In this way the settings of theJava Virtual Machine of the bach job cannot conflict with the JVM settings of the current job.Print-fit (PRTFIT) - This parameter may be used to fit the printout of a spreadsheet in a given number of pages. This parameter has two elements:

1. The first element (Sheet fit-width) tells into how many pages the width of the spreadsheet should be compressed.For instance, if the width of the spreadsheet usually requires two pages in order to print all the columns of a given spreadsheet row, by specifying 1in this element you force all the columns of a row to fit in a single page.

2. The second element (Sheet fit-height) tells into how many pages the height of the spreadsheet should be compressed.By leaving both elements set to 0, you are not asking any print compression.By setting both elements to 1, you are asking the printout to fit in a single page.

Note- This parameter, when used, inhibits the use of parameter PRTSCALENote: This parameter works only if the extension of the workbook is xls .Print-scale (PRTSCALE) - Percent scale to be used for printing. For instance, a value of 75 means that the print scale should be reduced to 75%.Note: This parameter works only if the extension of the workbook is xls .

Note- Command TABLEXLS provides, for any generated worksheet, a record in file QTEMP/XLSGENRPT. For the record layout, see this page.Command HSSFCGI/RPTXLSGEN reads this file and provides a printout listing all the workbooks, with information about their sheets, generated from the current job.

Command TABLEXLS is for a 5250 black-green screen or for execution within a program.

HSSFCGI Developer Guide

31

Page 32: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

Then, how to run this command from a WEB browser?If you have installed the Apache HTTP directives in stream file /hssfcgi/apache/http_directives.txt, just try one of the following URL's:

http://.../tablexls or http://.../hssfcgip/webtablexl.pgm

You will receive the following page:

HSSFCGI Developer Guide

32

Page 33: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

HSSFCGI Developer Guide

33

Page 34: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

Figure 6 - Command TABLEXLS from a WEB browser

Two options are provided for submitting the TABLEXLS command:

1. Press the button "create spreasheet" without checking the check-box "run in a separate batch job".In this way, the TABLEXLS command is executed from the HTTP server job.As soon as the spreadsheet has been created, it is sent to the browser for download then it is deleted.

2. Press the button "create spreasheet" after checking the check-box "run in a separate batch job".In this way the HTTP server job submits the execution of the TABLEXLS to a batch job.Buttons are made available to inquiry about the status of the submitted job.Once the submitted job completes, a download button shows up so that the spreadsheet can be sent for download to the browser and then deleted.

Notes.1. The WEB page includes a yellow "demo" button in the bottom left corner. A cycle of three demos is available. This can be used to get some familiarity

with the tool.You may try now, just use the "demo" button. Press this link to go.

2. If, after pressing the "submit" button, command TABLEXLS - launched from the CGI program - fails, the command in error is displayed at the bottom ofthe page. You are suggested to copy, paste and run it from a green screen session in order to receive some diagnostic messages.

HSSFCGI Developer Guide

34

Page 35: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

Last modified on 09/21/2019 23:03:30

HSSFCGITABLEXLS2: Create Excel workbooks from IBMi database files

Command TABLEXLS2 is the Junior version of command XLSTABLE.It is 1.3 times faster than TABLEXLS, does not require the ILE-RPG compiler to run, but has less features.

1-Highlights2-About the XLSGEN2 language3-Generating the XLSGEN2 script from your ILE-RPG program4-Commands XLSGEN2 and XLSXGEN25-Command WEBXLSGEN2 for CGI programs6-XLSTABLE2 for the WEB

1-Highlights

While command TABLEXLS generates - for each database file to be read - an ad hoc ILE-RPG program, command TABLEXLS2 does not need that.Therefore, to run command TABLEXLS2 you do not need an ILE-RPG compiler. This may help if you want to run it on a production box hosting no compilers.TABLEXLS2 generates an intermediate XLSGEN2 script made of some XML-like XLSGEN statements and data exported from a CPYTOIMPF command. Thegeneration of this script is quicker than the XLSGEN script generated from command TABLEXLS, and this is the performance advantage of XLSTABLE2.The script is then read by program XLSGEN2, similar to program XLSGEN, which creates an XLS or XLSX Excel workbook.The following parameters, available in command TABLEXLS, are missing in command TABLEXLS2:

RCDFMTNBR (only single formatted files are supported in parameter FROMFILE)INCLUDEXML (Include also an existing XML stream file)NULLDATE (null date display option)NULLTIME (null time display option)SKPFLDS (Skip fields by field test)IGNFLDS (Fields to be omitted)LINKFLDS (Hyperlink fields)PICTURES, VSPAN, WIDTH (Ability to display pictures)

2-About the XLSGEN2 language

HSSFCGI Developer Guide

35

perotti
Highlight
Page 36: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

A XLSGEN2 script begins as a XLSGEN script, defining the workbook, the worksheet and the first row of cells containing the column headers.However, instead of defining the row cells (containing the record field data) through the XLSGEN <row> <cell> and <data> tags, XLSGEN2 appends to the scriptstream file the output from a CPYTOIMPF command over the database file member. The result is a sequence of lines, one for each database record, where data fieldsare represented by semicolumn-separated strings.Character strings are enclosed in double quotes (example: ;"...text...";), while numbers are not (example: ;1827;).In XLSGEN2, this bunch of lines representing the database member records are preceded by the tag <Start_of_rows> and followed by the tag <End_of_rows>.

Please take a look at this XLSGEN2 script.It was generated by the following command:TABLEXLS2 FROMFILE(HSSFCGI/UTILITIES) TOXML('/hssfcgi/tmp/uti2.txt') TOXLS('/hssfcgi/tmp/uti2.xls') SHEETNAME(DT150903) PRTORIENT(*LANDSCAPE) PRTSCALE(75) HDGCOLOR(LAVENDER) XLSGENRPT(*NO)

After generating the XLSGEN2 script stream file, TABLEXLS2 inputs that XLSGEN2 stream file to command XLSGEN2, in order to generate the Excel workbook.In the above example, the XLSGEN2 command executed from TABLEXLS2 is:XLSGEN2 INPSTMF('/hssfcgi/tmp/uti2.txt') OUTSTMF('/hssfcgi/tmp/uti2.xls') FROZEN(1 0) HDGCOLOR(LAVENDER) XLSGENRPT(*NO)and the result is this Excel spreadsheet.

3-Generating the XLSGEN2 script from your ILE-RPG program

If you are familiar with CGIDEV2-based ILE-RPG programs, you may still use the template /hssfcgi/html/XLSGEN_template.txt to generate the initial part ofthe XLSGEN2 script (defining the workbook, the worksheet and the first row of cells containing the column headers) in the client output buffer and send it toyour script stream file using CGIDEV2 procedure WrtHtmlToStmf().Otherwise, if you are familiar with opening, closing and writing to stream files, you can do write that initial part of the script stream file using standard open(),write() and close() procedures.If you need some example, please refer to member TABLEXLS2 in HSSFCGI/QRPGLESRC.Next, you have to

open the script stream file for appendwrite the tag <Start_of_rows>use command CPYTOIMPF (referring to a given database file member) to add its output to the script stream filewrite the tag <End_of_rows>Last, you must write the following final tags to the script stream file: </worksheet> </workbook></XML>

Again, you may look at member TABLEXLS2 in HSSFCGI/QRPGLESRC for a complete example of generating a XLSGEN2 script.

4-Commands XLSGEN2 and XLSXGEN2

Command XLSGEN2 generates a XLS Excel workbook from a XLSGEN2 script stream file.Command XLSXGEN2 generates a XLSX Excel workbook from a XLSGEN2 script stream file.These commands are similar to commands XLSGEN and XLSXGEN (see this page), except that they do no support parameter CVTDATE.

5-Command WEBXLSGEN2 for CGI programs

HSSFCGI Developer Guide

36

Page 37: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

In writing you CGI program you may also take advantage of command HSSFCGI/WEBXLSGEN2. This command is very similar to commands XLSGEN2 andXLSXGEN2, but provides further functions:

a. Creates the XLS or XLSX stream file from the XLSGEN2 script stream file (as commmands XLSGEN2 or XLSXGEN2 would do). Then, if running in a HTTPinstance, ...

b. Sends the XLS or XLSX stream file to the browserc. Submits a job to delete the XLS/XLSX stream file after 5 minutes.

(Note that it is a program responsibility to decide to delete the XLSGEN2 script stream file.)

6-XLSTABLE2 for the WEB

Command TABLEXLS2 is for a 5250 black-green screen or for execution within a program.Then, how to run this command from a WEB browser?If you have installed the Apache HTTP directives in stream file /hssfcgi/apache/http_directives.txt, just try one of the following URL's:

http://.../tablexls2 or http://.../hssfcgip/webtablex2.pgm

You will receive the following page:

HSSFCGI Developer Guide

37

Page 38: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

Figure 7 - Command TABLEXLS2 from a WEB browser

Two options are provided for submitting the TABLEXLS2 command:

1. Press the button "create spreasheet" without checking the check-box "run in a separate batch job".In this way, the TABLEXLS2 command is executed from the HTTP server job.As soon as the spreadsheet has been created, it is sent to the browser for download then it is deleted.

2. Press the button "create spreasheet" after checking the check-box "run in a separate batch job".In this way the HTTP server job submits the execution of the TABLEXLS2 to a batch job.Buttons are made available to inquiry about the status of the submitted job.Once the submitted job completes, a download button shows up so that the spreadsheet can be sent for download to the browser and then deleted.

HSSFCGI Developer Guide

38

Page 39: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

Notes.1. The WEB page includes a yellow "demo" button in the bottom left corner. This can be used to get some familiarity with the tool.

You may try now, just use the "demo" button. Press this link to go.2. If, after pressing the "submit" button, command TABLEXLS2 - launched from the CGI program - fails, the command in error is displayed at the bottom of

the page. You are suggested to copy, paste and run it from a green screen session in order to receive some diagnostic messages.

HSSFCGI Developer Guide

39

Page 40: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

Last modified on 08/08/2019 19:07:21

HSSFCGITABLEXLS

Banners

1. Why2. How

3. An example4. Some tips

5. Special cases

1-WhyA possible problem with TABLEXLS generated Excel spreadsheets is that they, while are rather easily produced, look always the same and in the long run it maybecome difficult to distinguish one from the others, unless you find something relevant within the spreadsheet data itself.As a matter of fact, should you be given one, it would pretty difficult to understand at a first glance where it comes from, what it is about and when it was generated.

This is why some users of the tool were asking for a spreadsheet banner which could identify its source, its contents and its date.

2-HowCommand TABLEXLS has already so many parameters, that adding a few ones for defining a banner was out of discussion.The idea was then to create a "banner definition file" to add a single parameter - identifying the banner definition to be used - to command TABLEXLS.So, here is how it works:

Physical file HSSFCGIDTA/BANNERS collects banner definitions. Banner definition records have a unique numeric key(In this way you might dynamically create through your programs temporary banner definitions to be subsequently used in a dynamic TABLEXLS command).

a.

Command HSSFCGI/WRKBAN allows to manually maintain banner definitions in file HSSFCGIDTA/BANNERS.b. A new parameter - BANNERID - in commands TABLEXLS and TABLEXLS2 is used to identify the banner definition to be used (leave the default value *NONEto skip banner production).

c.

If requested for a spreadsheet banner, command TABLEXLS generates, at the beginning of its XLSGEN script, some extra code used by XLSGEN programs togenerate banner rows at the top of the generated spreadsheet.

d.

3-An exampleLet's go through an example. You can practice this example yourself, everything is available in your HSSFCGI.

Run command HSSFCGI/WRKBAN.1.

HSSFCGI Developer Guide

40

perotti
Highlight
Page 41: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

The following shows up:

WRKBAN - Work with Banners FRANKIE

No banners so far. Press F6 to add.

F3=End F6=Add F12=Previous

Figure 1Press F6:

WRKBAN - Work with Banners FRANKIE Type data and press the Enter key to add a new banner. ID ................ 0 Picture path ...... Title ............. Subtitle .......... Picture rows ...... 0 Picture columns ... 0 Title columns ..... 0 (0=automated)

F3=End F12=Previous

Figure 2

2.

Enter the following data and press the Enter key:

WRKBAN - Work with Banners FRANKIE Type data and press the Enter key to add a new banner. ID ................ 1 Picture path ...... /hssfcgi/graphics/giovanni.png Title ............. Easy400.net site downloaders Subtitle .......... up to August 8, 2019 Picture rows ...... 3 Picture columns ... 1

3.

HSSFCGI Developer Guide

41

Page 42: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

Title columns ..... 0 (0=automated)

F3=End F12=Previous

Figure 3Meaning of the data entered:

ID - The identifier of this banner definition. It will be mentioned in parameter BANNARID of command TABLEXLS.Picture path - path and name of the (optional) picture that will show up in the banner.WARNING - Only pictures with extent JPG, JPEG and PNG are supported.Title - An (optional) title for the spreadsheet. Will show up in the banner.Subtitle - A (optional) subtitle for the spreadsheet. Will also show up in the banner.Note 1 - The three items are all optional, but at least one of them should be specified.Picture rows and columns - The picture is anchored on the top left corner of the banner and is sized by the number of spreadsheets rows and columnsspecified. Note 2 - If no picture specified (Picture path is left blank), Picture columns must be set to zero.Picture rows can never be zero, because it tells the number of rows taken by the banner.Title columns - Title and subtitle, if existing, occupy a number of spreadsheet columns at the right of the picture.This number tells how many columns should be taken.If you specify zero, then title and subtitle will take all the remaining columns at the right of the picture.Note 3 - Title and subtitle texts are centered in the column space assigned to them.

The initial screen now contains the following:

WRKBAN - Work with Banners FRANKIE Enter choice and press Enter. Position to: 1=Display, 2=Change, 4=Delete, 7=Duplicate ID Properties 1 /hssfcgi/graphics/giovanni.png Easy400.net site downloaders up to August 8, 2019 -Picture rows: 3 -Picture col.s: 1 -Title col.s: 0 (0=automated)

Bottom F3=End F6=Add F12=Previous

Figure 4WRKBAN allows to easily add new items and to update the existing ones.Full help text is available behind the screens (use F1).

4.

Let us now create a bannered spreadsheet.Run the following command:HSSFCGI/TABLEXLS FROMFILE(HSSFCGI/UTILS) TOXLS('/tmp/utils.xls') BANNERID(1) HDGCOLOR(INDIGO) FROZEN(6) IGNFLDS(UTISEQ UTIURL UTICHARGE)to obtain the following "bannered" spreadsheet:

5.

HSSFCGI Developer Guide

42

Page 43: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

Figure 5

4-Some tips

Background colorIts is highly recommended to use a background color to come up with a solid banner.The background color must be specified in parameter HDGCOLOR (ColHdg background color) of command XLSTABLE (or XLSTABLE2).Column headers and banner are always given tnhe same background color.Picture distorsionAs the picture is anchored to a user-specified number of rows and columns, though looking all right at test phase, it may become suffer from distorsion whenone of the columns happens to be shrinked or streched because of their contents.It is therefore recommended to be very carefull in using pictures representing objects having a well known geometry."Fluid" images, such as landscapes, flowers, clouds, abstract pictures, etc. usually have no problems.Title / Subtitle on multiple linesYou may break the title and/or the subtitle by inserting the sequence %LF (Line Feed) in their texts, once or more times.By doing so, the row height increases and that may cause picture distorsion (you may try to balance it by increasing the number of columns assigned to thepicture).

HSSFCGI Developer Guide

43

Page 44: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

5-Special cases

No picture

Picture path ...... *NONE Title ............. Easy400.net%LFsite downloadersSubtitle .......... up to August 8, 2019 Picture rows ...... 3 Picture columns ... 0 Title columns ..... 0 (0=automated)

Figure 6

i.

No subtitle

Picture path ...... /hssfcgi/images/sestri_levante.jpgTitle ............. Easy400.net%LFsite downloaders Subtitle .......... *NONE Picture rows ...... 2Picture columns ... 3

ii.

HSSFCGI Developer Guide

44

Page 45: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

Title columns ..... 0 (0=automated)

Figure 7No title, no subtitle

Picture path ...... /hssfcgi/images/sestri_levante.jpgTitle ............. *NONE Subtitle .......... *NONE Picture rows ...... 10Picture columns ... 4Title columns ..... 0 (0=automated)

Figure 8

iii.

HSSFCGI Developer Guide

45

Page 46: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

Last modified on 08/08/2019 19:07:22

HSSFCGITABLEXLSparameter

INCLUDEXML

1. What2. How

3. An example

1-WhatAnother TABLEXLS user need is similar to the banner case, but is somehow different.While a banner rows must sit on the top of a spreadsheet, this other need would be the ability to inser a row, or a group of rows within the "body" of a spreadsheet.That could be a subbanner, a rows delimiter or a trail row.

2-HowSuch a need can be implemented with parameter INCLUDEXML of command TABLEXLS.This parameter is made of two elements:

the name of a stream file containing XLSGEN statements for the row or the group of rows to be included1. a parameter telling the row number of the spreadsheet where these XLSGEN statements will be included.2.

The stream file containing XLSGEN statements to be included in the spreadsheet requires some XLSGEN language knowledge to be built.It may be built manually, or dynamically by a user program, or picking up a group of XLSGEN statements from an existing XLSGEN (XML-like) stream file by usingcommand HSSFCGI/GETXMLROWS.

The second parameter tells where in the spreadsheet the inclusion must take place. This is done by specifying the number of the row that will follow the inclusion. A 1means that the inclusion will take place before the first row of the spreadsheet, usually before the column headers (rows belonging to a banner should never beaccounted for). Special value *START stays for row 1. Special value *END stays for the very end of the spreadsheet body.

3-An exampleLet us take the case of a spreadsheet featuring a banner, the one created with commandHSSFCGI/TABLEXLS FROMFILE(HSSFCGI/UTILS) TOXLS('/tmp/utils.xls') BANNERID(1) HDGCOLOR(INDIGO) FROZEN(6) IGNFLDS(UTISEQ UTIURL UTICHARGE):

HSSFCGI Developer Guide

46

perotti
Highlight
Page 47: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

Figure 1Now, what we want is to include an orange row containing some text, just before the body of this spreadsheet.This is how we do it:

We need to write a small stream file containing the XLSGEN statements defining the rows to be included. An example is available in stream file /hssfcgi/examples/INCLUDEXMLexample.txt and is look as follow:

<row row-height="18"> <cell hspan="4"> <data type="LargeTextC" italic wrap b-color="ORANGE" f-color="INDIGO"> Spreadsheet generated on IBM i with command HSSFCGI/TABLEXLS </data> </cell></row>

Figure 2

1.

In the previous TABLEXLS command we must add parameter INCLUDEXML as follow:

HSSFCGI/TABLEXLS FROMFILE(HSSFCGI/UTILS) TOXLS('/tmp/utils.xls') BANNERID(1) HDGCOLOR(INDIGO) FROZEN(6) IGNFLDS(UTISEQ UTIURL UTICHARGE) INCLUDEXML('/tmp/includexmlexample.txt' *START)

Figure 3

2.

HSSFCGI Developer Guide

47

Page 48: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

The result id the following spreadsheet:

Figure 3

Try it yourself!

HSSFCGI Developer Guide

48

Page 49: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

Last modified on 01/08/2017 00:34:54

HSSFCGIRight to left

HSSFCGI includes a feature that forces generated worksheets to display their columns from right to left, instead of from left to right.Unluckily, this feature requires at least V5R4 (POI 3.6) and works only for spreasheets with extension XLS (MS Office 2003).

This is how you can use this feature:

If you already have a stream file containing an Excel workbook and you want to force a worksheet there to be displayed right to left, you may use commandHSSFCGI/SETRTL:

Set W/S right-to-left (SETRTL) Type choices, press Enter. Workbook path . . . . . . . . . WBOOK Worksheet name . . . . . . . . . WSHEET

Command parameters:Workbook path (WBOOK) - IFS path and name of the stream file containing the workbook.Example: /tmp/utils.xlsWorksheet name (WSHEET) - Name of the worksheet to be displayed right to left. Be careful: it is case sensitive.

Command example:HSSFCGI/SETRTL WBOOK('/tmp/utils.xls') WSHEET('UTILS')

1.

If you are generating from your program some XLSGEN stream file to be subsequently interpreted by command HSSFCGI/XLSGEN, in order to set aworksheet to the right-to-left display mode, insert the keyword SETRTL in the <worksheet ...> tag. Example<worksheet name="2016" setrtl>

2.

If you are generating an Excel workbook with command HSSFCGI/TABLEXLS or command HSSFCGI/TABLEXLS2, in order to set to the right-to-left displaymode all the worksheets there, make sure to specify the command parameterSETRTL(*YES).

3.

If you are using the HSSFCGI WEB program webtablexl or webtablex2 to generate and send an Excel worksheet to your browser, select the yesSETRTL radio button to force the right to left display.

4.

HSSFCGI Developer Guide

49

perotti
Highlight
Page 50: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

Last modified on 01/09/2017 15:11:45

HSSFCGIThe XLSUPD language

The XLSUPD languageThe XLSUPD and the XLSXUPD commandsAn exampleThe XLSUPD language rulesFacilities for CGIDEV2-based programs

The XLSUPD language

The XLSUPD language is a special version of the XLSGEN language that is used to update existing XLS or XLSX spreadsheets, whatever way they may have beencreated (through XLSGEN or in some other way).

1. The XLSUPD and the XLSXUPD commands

These two commands are exactly the same: XLSUPD is used to update a XLS spreadsheet, while XLSXUPD is used to update a XLSX spreadsheet.

An IFS stream file, containing XLSUPD language control statements for each spreadsheet cell to be updated, must be provided in parameter SHEETIN.

The following types of update can be performed:Update the value of an existing cell, while preserving its properties (like data type, font, colors, etc.)1. Update the value and all the properties of an existing cell: the cell is re-created.2. Create a new cell in an existing or in a new spreadsheet row.3.

Update a XLS Excel spreadsheet (XLSUPD) Type choices, press Enter.

Workbook to be updated . . . . . WRKBOOKIN Updated workbook . . . . . . . . WRKBOOKOUT Name of sheet to be updated . . SHEETIN Input XML stream file . . . . . INPSTMF Decimal positions . . . . . . . DECPOS *AUTO 0-9, *AUTO, *NOC Display zero values . . . . . . ZERODSP *YES *YES, *NO Format all date cells as . . . . CVTDATE *NO *NO, *MDY, *DMY, *YMD...

Figure 1- Command HSSFCGI/XLSUPD

Command parametersWorkbook to be updated (WRKBOOKIN) - This is the IFS stream file of the Excel workbook containing the spreadsheet to be updated.Updated workbook (WRKBOOKOUT) - This is the IFS stream file that will contain the updated spreadsheet:

Enter *SAME if you want the update be performed on the workbook specified in parameter WRKBOOKINIf you want the original workbook be preserved from changes, in this parameter specify the name of an IFS stream file that will contain the updatedcopy of the original workbook.If already existing, this stream file will be deleted and re-created.

Name of sheet to be updated (SHEETIN) - The name of the spreadsheet - in workbook WRKBOOKIN - that will be updated.This name is not case sensitive.Input XML stream file (INPSTMF) - The name of the XML-like IFS stream file containing the XLSUPD control statements used to perform the spreadsheet cellupdates.The following parameters are used only when re-creating an existing cell or creating a new cell and its data type is NUMBER or DATE :

Decimal positions (DECPOS) - This parameter defines the number of decimal positions for numeric cellsIf you specify a number from 0 to 9, the numeric cells display that number of decimal positions.The thousand separator is displayed.If you specify *AUTO, the numeric cells display the number of decimal positions specified in the control statements for that cell in the XLSUPDstream file specified in parameter INPSTMF.The thousand separator is displayed.If you specify *NOC, the numeric cells display the number of decimal positions specified in the control statements for that cell in the XLSUPDstream file specified in parameter INPSTMF.This is the same as *AUTO, but the thousand separator is not displayed.

Display zero values (ZERODSP) - This parameter tells whether numeric cells containing a zero value should display a zero or just nothing. Select:*YES (default value) to have the numeric cells containing a zero value displaying a zero*NO to have the numeric cells containing a zero value displaying nothing. This option is recommended when a large number of numeric cellsmay contain zero values, because this makes user reading much easier.

Format date cells as ... (CVTDATE) - This parameter tells whether date cells should be formatted for a given date format, overriding the formatspecified for a given date cell in the XLSUPD control statements (parameter STMFIN).Leave *NO if no override must take place.Available overriding formats are:*MDY mm/dd/yy)*DMY dd/mm/yy*DMYY dd/mm/yyyy*YMD yy/mm/dd*YYMD yyyy/mm/dd*ISO yyyy-mm-dd*USA mm/dd/yyyy*EUR dd.mm.yyyy*JIS yyyy-mm-dd*JUL yyyy-ddd

HSSFCGI Developer Guide

50

perotti
Highlight
Page 51: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

2. An example

The following example may help understanding how these commands (XLSUPD and XLSXUPD) work.The example shows the case where spreadsheet 10-05 of workbook /hssfcgi/tmp/famacc.xls is updated to workbook /tmp/famacc2.xls.

Spreadsheet before update/hssfcgi/tmp/famacc.xls

Spreadsheet after update/tmp/famacc2.xls

XLSUPD WRKBOOKIN('/hssfcgi/tmp/famacc.xls') WRKBOOKOUT('/tmp/famacc2.xls') SHEETIN('2010-05') INPSTMF('/hssfcgi/tmp/famacc_upd.txt')

Command used to perform the spreasheet update

<XML> <XLSUPD> <cell col="H" row="3"><data type="number">1377</data></cell> <cell col="8" row="10" border> <data type="number" f-color="blue" b-color="gold" bold underline italic>502</data> </cell> <cell col="A" row="36"><data type="text">New formula -></data></cell> <cell col="B" row="36"><data type="formula">B21-B27</data></cell> <cell name="A37" hspan="11" border> <data type="largetextc" f-color="white" b-color="indigo" bold>END OF THIS SPREADSHEET</data> </cell> </XLSUPD></XML>

XLSUPD language stream file input to command XLSUPD aboveINPSTMF('/hssfcgi/tmp/famacc_upd.txt')

Meaning of XLSUPD control statements in stream file /hssfcgi/tmp/famacc_upd.txt:update of the cell H3:

<cell col="H" row="3">identifies the cell to be updated<data type="number">1377</data>identifies the new cell value.Notes

The data type (keyword type="...") must always be specified and must match the data type of the cell to be updated.a. In this case, no properties are changed, the cell is updated with a new value and its original properties are retained.b.

update of the cell H10:<cell col="H" row="10">identifies the cell to be updated<data type="number" f-color="blue" b-color="gold" bold underline italic>502</data>identifies the new properties and the the new value of the cell.Notes

When some cell properties are specified (such as f-color, b-color, bold, underline, italic, ...) the cell is completelyre-created, though it retains its original data type.

a.

update of the cell A36:This is a case similar to that of cell H3, except that the data type is now text.The cell is just updated with a new value.

update of the cell B36:This is a case similar to that of cell H3, except that the data type is now formula.The cell is just updated with a new value.

creation of the cell A37:In the original spreasheet there was no cell A37, therefore it had to br created with the properties and the value specified.

3. The XLSUPD language rules

Prolog and epilog - Prolog <XML><XLSUPD> and Epilog </XLSUPD></XML> are optional.1. Tag structure -

Tags are not case sensitive.Example: <cell ...> and <CELL ...> have the same meaning.

a.

Keywords and their values are not case sensitive.Example: type="number", TYPE="number" and TYPE="NUMBER" are the same.

b.

Keywords within a tag can be in any order.Example: col="A" row="37" and row="37" col="A" are the same.

c.

Keyword values must always be within double quotes.Example: row="37"

d.

<data>...</data> values are case sensitive.Example: <data type="text">apple</data> and <data type="text">APPLE</data> are different values.

e.

2.

Cell identification -The tag sequence <cell ...><data ... ></data></cell>is mandatory. All the above four tags must be there in the appropriate sequence. If that is not done, the related cell update is discarded.

a.

A cell must be always be identified througheither keyword name, example:name="H10"or keywords col (colunm number/name) and row (row number), examples:col="H" row="10" orcol="8" row="10"The data type of an existing cell must always be correctly mentioned in the <data type="..." > keyword.

An existing numeric cell can be referred to by a data type containing the string number

b.

3.

HSSFCGI Developer Guide

51

Page 52: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

An existing character string cell can be referred to by a data type containing the string text or by data type column-headerAn existing formula cell must be referred to by data type formula

Cell update vs (re-)creation -Only existing cells with type numeric, string and formula can be updated.Existing cells with other types, such as date, picture and so on, are re-created instead of being updated (though in terms of final result this makes nodifference if the new properties match the previous ones).

a.

If any cell or data properties specified (example: cell keyword border; data keywords bold underline, italic, wrap, valign, f-color, b-color), the cell isre-created and the new properties replace the existing ones.

b.

4.

NOTE- For the available keywords and their meanings, please refer to the XLSGEN language.

4. Facilities for CGIDEV2-based programs

If you are familiar ewith CGIDEV2-based programming, you may easily create a XLSUPD language control stream file by using procedures UpdHtmlVar(), WrtSection()and WrtHtmlToStmf().The only thing you may be missing is an external template stream file to be loaded via procedure GetHtmlIfs() or procedure GetHtmlIfsMult().In such a case, you may use as template the stream file /hssfcgi/html/XLSUPD_template.txt, which looks as follow:

<as400>top<XML> <XLSUPD><as400>cell <cell row="/%row%/" col="/%col%/" /%cellkeywords%/> <data type="/%datatype%/" /%datakeywords%/> /%data%/ </data> </cell><as400>bot </XLSUPD></XML>

HSSFCGI Developer Guide

52

Page 53: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

Last modified on 01/08/2017 00:34:55

HSSFCGIScott Klement's Demos

If you do not want to take advantage from the HSSFCGI XLSGEN language or from the TABLEXLS command, but you would rather like to create EXCELspreadsheets through your own ILE-RPG programs based on Scott Klement's HSSFR4 service program, you can retrieve all the material you need in libraryHSSFCGI.

Here is a list of the material you may need:

Presentation and articles1. You may find Scott's HSSF presentation from from here and his HSSF articles from here.

HSSFR4 service program2. Library HSSFCGI contains two versions of the Scott Klement's HSSFR4 service program:

HSSFR4_1 for POI 3.2 ; procedure prototypes are in HSSFCGI/QRPGLESRC1 member HSSF_H.HSSFR4_2 for POI 3.6 ; procedure prototypes are in HSSFCGI/QRPGLESRC2 member HSSF_H.

Library HSSFCGI contains other service programs:HSSFCGIX: functions used for XLSGEN, TABLEXLS, etc. Some functions are also used in my versions of the Scott's demos.Procedure prototypes are in HSSFCGI/QRPGLESRC member HSSFCGIX_P.HSSFCGI: this is a duplicate of service program CGIDEV2/CGISRVPGM2, should you ever need to write a CGI program.Procedure prototypes are in HSSFCGI/QRPGLESRC member PROTOTYPEB.

.

Binding directories3. Library HSSFCGI contains the following binding directories:

HSSF_1: it binds to service programs HSSFR4_1, HSSFCGIX, HSSFCGI, QZHBCGI.It should be used for creating Excel spreadsheets based on POI 3.2 .HSSF_2: it binds to service programs HSSFR4_2, HSSFCGIX, HSSFCGI, QZHBCGI.It should be used for creating Excel spreadsheets based on POI 3.6 .

Scott's Demos4. Very useful for learning a number of POI procedures.

POI 3.2a. The following demos use POI 3.2 when running on an OS/400 release lower than V6R1, otherwise they use POI 3.6 .Their sources are in HSSFCGI/QRPGLESRC1.ADDPIC_1 Loading an image into an Excel spreadsheetCOLORS_1 Fills and colorsHDRDEMO_1 Setting headers, footers & repeating rowsXLCRTDEM_1 Using HSSF to create a complex Excel wrkbookXLHELLO_1 Sample HelloWorld spreadsheet creationPOI 3.6b. The following demos require at least OS/400 V6R1 and use POI 3.6 .Their sources are in HSSFCGI/QRPGLESRC2.ADDPIC_2 Loading an image into an Excel spreadsheetCOLORDEM_2 Fills and colorsHDRDEMO_2 Setting headers, footers & repeating rowsXLCRTDEM_2 Using HSSF to create a complex Excel wrkbookUPDDEMO_2 Read/Update Excel Spreadsheet

Sample skeleton programs5. We suggest that - in writing your own ILE-RPG programs for creating/accessing EXCEL workbooks Scott Klements HSSFR4 POI procedures - you use someof the tools already available in library HSSFCGI.However DO NOT create your objects (e.g. programs) in library HSSFCGI. Create them in your own library to avoid the risk of losing them when refreshinglibrary HSSFCGI.The following two examples of skeleton programs may help in starting your coding:

For V5R3 only *======================================================================== * This is the sample skeleton of an ILE-RPG program * intended to work with POI 3.2 HSSF * for creating or accessing an XLS Excel workbook. * * CRTBNDRPG PGM(*CURLIB/SAMPLEV5R3) SRCFILE(*CURLIB/QRPGLESRC1) * DFTACTGRP(*NO) ACTGRP(*CALLER) DBGVIEW(*LIST) * *======================================================================== * The following /copy sets the binding directory HSSFCGI/HSSF_1. * This binding directory binds to service program HSSFCGI/HSSFR4_1, * the Scott Klement's procedures interfacing POI 3.2 HSSF /copy HSSFCGI/qrpglesrc,hspecsbnd * The following /copy defines the procedure prototypes of service program HSSFCGI/HSSFR4_1 /copy HSSFCGI/qrpglesrc1,hssf_h * The following /copy defines the procedure prototypes of service program HSSFCGI/HSSFCGIX, * such as SetJava14() /copy HSSFCGI/qrpglesrc,hssfcgix_p * ... ... ... other procedure prototypes and variables ... ... ... /free // the following procedure // - adds the environment variable CLASSPATH to address the POI 3.2 Java objects // in directory /hssfcgi/java/poi3.2 // - adds the environment variable QIBM_RPG_JAVA_PROPERTIES for using // Java version 1.4 (Java 4.0) SetJava14(); // ... ... ... program statements ... ... ...

A.

HSSFCGI Developer Guide

53

perotti
Highlight
Page 54: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

*inlr=*on;

For V5R4 and any furter OS/400 release *======================================================================== * This is the sample skeleton of an ILE-RPG program * intended to work with POI 3.6 HSSF * for creating or accessing an XLS Excel workbook. * * CRTBNDRPG PGM(*CURLIB/SAMPLEV5R4) SRCFILE(*CURLIB/QRPGLESRC2) * DFTACTGRP(*NO) ACTGRP(*CALLER) DBGVIEW(*LIST) * *======================================================================== * The following /copy sets the binding directory HSSFCGI/HSSF_2. * This binding directory binds to service program HSSFCGI/HSSFR4_2, * the Scott Klement's procedures interfacing POI 3.6 HSSF /copy HSSFCGI/qrpglesrc,hspecsbnd2 * The following /copy defines the procedure prototypes of service program HSSFCGI/HSSFR4_2 /copy HSSFCGI/qrpglesrc2,hssf_h * The following /copy defines the procedure prototypes of service program HSSFCGI/HSSFCGIX, * such as SetJava15() /copy HSSFCGI/qrpglesrc,hssfcgix_p * ... ... ... other procedure prototypes and variables ... ... ... /free // the following procedure // - adds the environment variable CLASSPATH to address the POI 3.6 Java objects // in directory /hssfcgi/java/poi3.6 // - adds the appropriate Java environment variables for using the most appropriate // Java Version among those installed on the IBM i SetJava15(); // ... ... ... program statements ... ... ... *inlr=*on;

B.

HSSFCGI Developer Guide

54

Page 55: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

Last modified on 05/11/2019 14:22:51

HSSFCGIJVMSTARTUP

Programmers used to work with library lists may have some problems in understanding how the JVM (Java Virtual Machine) works in retrieving Java "programs".The following may help in understanding what goes on and how a developer can master it.

About JAR filesJava code resides in Java classes. Stream files with extension JAR are collections of Java classes. In other words, a JAR file can be understood as alibrary of programs.

1.

IFS directory /QIBM/userdata/java400/ext may contain several Java classes. These Java classes make up something like a Default Library List forJava classes.

2.

The CLASSPATH environment variable is a list of JAR files. It can therefore be understood as a Library List for Java classes.3. The environment variable CLASSPATH is mandatory when some of the Java code to be executed is in a directory other than /QIBM/userdata/java400/ext and must be set before that the JVM is started. Once started, the JVM cannot be restarted.

4.

A.

JAR files in HSSFCGI and XLPARSE2HSSFCGI jar files are in subdirectories of IFS directory /HSSFCGI/javaXLPARSE2 jar files are in subdirectories of IFS directory /XLPARSE2/javaHSSFCGI2 and XLPARSE2 jar files are the sameHSSFCGI and XLSPARSE2 programs calling Java classes use each a separate CLASSPATH string, mentioning their jar files. However, as the jar filesare the same for both the utilities, there two CLASSPATHs are interchangeable.Both HSSFCGI and XLPARSE2 feature a command, SETDFTJARS, that copies their jar files (identical for both the tools) to IFS directory/QIBM/userdata/java400/ext. This could be of some help when CLASSPATHs look like having problems. Both Both HSSFCGI and XLPARSE2feature another command, RMVDFTJARS, that removes thier jar files from IFS directory /QIBM/userdata/java400/ext.

B.

Jobs running multiple Java productsJobs running both HSSFCGI programs and XLPARSE2 programs have no JVM problems.1. Jobs running other Java products plus HSSFCGI and/or XLPARSE2 may have JVM troubles.Such troubles may by solved by running command HSSFCGI/JVMSTARTUP or XLPARSE2/JVMSTARTUP as soon as a job is started or before executingany application using the JVM.This command sets up the JVM environment for HSSFCGI and XLPARSE2 and optionally extends the classpath through a string provided in a parameterof this command.This makes sure that HSSFCGI and XLPARSE2 java code can run, whatever other mix of java programs is going to be executed.

2.

C.

In case of unsolved JVM problemsIf a mix of HSSFCGI/XLPARSE2 and other Java products fails to run within a single job, the only way out is to submit to a batch job the execution of HSSFCGI orXLPARSE2 commands.

XLPARSE2 commands feature a SBMJOB parameter. That parameter allows to submit a command for execution in a separate batch job. The submittedjob is synchronized with the submitting job: that is, the submittiong job resumes execution after completion of the submitted job.Also HSSFCGI commands feature a SBMJOB parameter. However in this case the submitted job is not synchronized with the submitting one.

D.

HSSFCGI Developer Guide

55

perotti
Highlight
Page 56: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

Figure 2

Last modified on 01/16/2016

HSSFCGITABLEXLS - Parameter ALTCOLHDG

In generating worksheets, TABLEXLS would generally create a single row of column headers for each worksheet. The text for the column headers is retrieved from theFile-Field descriptions related to the processed database file.

Though this is generally acceptable, there may be cases where one would need to have different text descriptions in some column headings or even extend the headingsover more rows.

In command TABLEXLS you may use parameter ALTCOLHDG to replace the default column headings with your own headings. This can be done by specifying in thisparameter the path-name of a stream file where the heading rows are defined in XLSGEN language. The following example explains how this can be done.

The exampleIn this example we use database file HSSFCGIDTA/ADHOCCTL: that is a control file available on your system after installing HSSFCGI. We use this file because youcan repeat this example on your IBMi.

Step 1Let us run the following command:TABLEXLS FROMFILE(HSSFCGI/ADHOCCTL) TOXML('/tmp/adhocctl.txt') TOXLS('/tmp/adhocctl.xls')The resulting worksheet looks like this:

Figure 1

Step 2Let us have a look at the XLSGEN script generated by that command TABLEXLS (the XLSGEN script is then usedby command TABLEXLS to feed command XLSGEN, which creates the XLS). That XLSGEN script is in stream file/tmp/adhocctl.txt (See Figure 2).The part of the script that generates the column headings is the one inside the red rectangle.

If we want different headings from the default ones generated by TABLEXLS, we must write in a stream file ourXLSGEN tags, and mention that stream file in parameter ALTCOLHDG of command TABLEXLS.

Step 3Figure 3 shows the XLSGEN script that we would like to use for generating the column headers of the worksheet.Let us assume that we wrote this script in stream file /hssfcgi/altcolhdg/adhocctl.txt.

Step 4Let us now run the following command:TABLEXLS FROMFILE(HSSFCGIDTA/ADHOCCTL) TOXML('/tmp/adhocctl2.txt') TOXLS('/tmp/adhocctl2.xls') ALTCOLHDG('/hssfcgi/altcolhdg/adhocctl.txt')The resulting worksheet id shown in Figure 4.

Restrictions

The XLGEN script stream file mentioned in parameter ALTCOLHDG applies only to the members of the firstdatabase file in parameter FROMFILE. For the other database file members, column headings are retrievedfrom the related file-field descriptions.

HSSFCGI Developer Guide

56

perotti
Highlight
Page 57: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

Figure 3

Figure 4

HSSFCGI Developer Guide

57

Page 58: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

Last modified on 04/24/2019 18:01:01

Java product 5722JV1 / 5770JV1

Option Feature Description Javaversion Library IFS directory Java

Classic

IBMTechnology

for JavaV5R3 V5R4 V6R1 V7R1 V7R2 V7R3 V7R4

*BASE 5050+lng IBM Developer Kit for Java QJAVA x x x x x x x5 5105 Java Developer Kit 1.3 1.3 QJAVA /QIBM/ProdData/Java400/jdk13 x6 5106 Java Developer Kit 1.4 1.4 QJAVA /QIBM/ProdData/Java400/jdk14 x x x x7 5107 Java Developer Kit 5.0 1.5 QJAVA /QIBM/ProdData/Java400/jdk15 x x x x

8 5108 J2SE 5.0 32 bit 1.5 QJVM50 /QOpenSys/QIBM/ProdData/JavaVM/jdk50/32bit x x x x

9 5109 J2SE 5.0 64 bit 1.5 QJVM5064 /QOpenSys/QIBM/ProdData/JavaVM/jdk50/64bit x x x

10 5110 Java SE Development Kit 6 1.6 QJAVA /QIBM/ProdData/Java400/jdk6 x x x

11 5111 Java SE 6 32 bit 1.6 QJVM6032 /QOpenSys/QIBM/ProdData/JavaVM/jdk60/32bit x x x x x

12 5112 Java SE 6 64 bit 1.6 QJVM6064 /QOpenSys/QIBM/ProdData/JavaVM/jdk60/64bit x x x x

13 5113 Java Developer Kit (J2SE1.4.2 64-bit) 1.4 QJVM1464 /QOpenSys/QIBM/ProdData

/JavaVM/jdk14/64bit x x x

14 5114 Java SE 7 32 bit 1.7 QJVM7032 /QOpenSys/QIBM/ProdData/JavaVM/jdk70/32bit x x x x

15 5115 Java SE 7 64 bit 1.7 QJVM7064 /QOpenSys/QIBM/ProdData/JavaVM/jdk70/64bit x (x) (x) x

16 5116 Java SE 8 32 bit 1.8 QJVM8032 /QOpenSys/QIBM/ProdData/JavaVM/jdk80/32bit x (x) x x

17 5117 Java SE 8 64 bit 1.8 QJVM8064 /QOpenSys/QIBM/ProdData/JavaVM/jdk80/64bit x (x) x x

Reference: Support Java Versions by Operating System Release.

(x): not compatible with HSSFCGI and XLPARSE2

HSSFCGI Developer Guide

58

perotti
Highlight
Page 59: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

01/01/2021 18:57:15

Answers to some questions asked by HSSFCGI users.

1. Q: When running command HSSFCGI/TABLEXLS or HSSFCGI/XLSGEN, the following error is displayed:a. Escape program message:

ERROR in executing XLSGEN, see joblog previous messages.b. Previous diagnostic message:

Message . . . . : Java exception received when calling Java method.Last cell processed was row 0, column 0 in sheet *Unknown*. Joblog message Java exception received when calling Java method.Error RNX0301 in pgm HSSFCGI/XLSGEN_2 module XLSGEN_2 at stmt + 244600:"Java exception received when calling Java method."

c. Additional message information (via F1):Message ID . . . . . . : RNX0301 Severity . . . . . . . : 50Message type . . . . . : EscapeDate sent . . . . . . : xx/xx/xx Time sent . . . . . . : xx:xx:xxMessage . . . . : Java exception received when calling Java method.Cause . . . . . : RPG procedure XLSGEN_2 in program HSSFCGI/XLSGEN_2received Java exception "java.lang.NoClassDefFoundError:org.apache.poi.hssf.usermodel.HSSFWorkbook" when calling method ""with signature "()V" in class "org.apache.poi.hssf.usermodel.HSSFWorkbook".Recovery . . . : Contact the person responsible for program maintenance todetermine the cause of the problem.

What can I do About it?A: This is a very common case. The error is that a Java class, needed by service program HSSFCGI/HSSFR4, cannot be found.The way a Java class is retrieved by the Java Virtual Machine (JVM) is as follow:

I. A search is made in IFS directory /QIBM/UserData/Java400/ext. This directory works like a system library list.II. If the search is unsuccessful, then the search goes through the IFS directories mentioned in the environment variable CLASSPATH, which works like a

job library list.One major problem is that once the JVM has been started in a job, the current CLASSPATH is stored in its data, and cannot be changed even by changing thejob CLASSPATH. This restriction has the following consequences:

i. If the job has to process two or more applications using different classes, and each application sets up a different CLASSPATH, only the first applicationwill work, the subsequent ones will fail in retrieving their Java classes.

ii. To overcome this problem, Java application developers often do install their classes in the IFS directory /QIBM/UserData/Java400/ext. In this way, other

59

HSSFCGI Developer Guide

Page 60: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

problems may raise when different applications have classes with the same name, and class methods are different. This may happen when twoapplications, built over a given Java package (example: POI), require a different release of that package.Because of this, Java classes used by HSSFCGI are not in IFS directory /QIBM/UserData/Java400/ext, they are in IFS directory /hssfcgi/java, andHSSFCGI sets up the appropriate CLASSPATH environment variable before calling the JVM.

Once the above is understood, the ways to solve the NoClassDefFoundError are quite obvious:A. Make sure that IFS directory /QIBM/UserData/Java400/ext does not contain any POI-related and any XLPARSE-related objects.B. Run command WRKENVVAR(*SYS) and, if system level CLASSPATH environment variable is listed, remove it. Java applications should instead create

their own CLASSPATH env.var's.C. If your job must execute some other Java applications beside running HSSFCGI commands TABLEXLS and/or XLSGEN, in these HSSFCGI

commands specify the parameter SBMJOB(*YES). This parameter submits the execution of the command in a separate batch job and the submittingjob waits for the completion of the submitted one.

See also page JVMSTARTUP.

2. Q: Is it possible to have a cell text vertically rotated?A: Yes, by creating the Excel spreadsheet with some XLSGEN script and using the keyword rotate in tag <data>.Example: <data type="Column-Header" rotate="90"> .

3. Q: When using command TABLEXLS to create an Excel spreadsheet, how can I tell not to generate the first row cells as column headers?A: Just specify parameter COLHDGOPT(0) .

4. Q: How can I tell command TABLEXLS not to generate a cell depending on the contents of the related database field?A: Specify parameter SKPFLDS (Skip fields by field test).

5. Q: Is it possible, using XLSGEN, to generate spreadsheet cells containing drop down lists?A: No.

60

HSSFCGI Developer Guide

Page 61: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

<as400>startbook<XML> <workbook><as400>startsheet <worksheet name="/%sheetname%/" /%worksheetkeywords%/><as400>startrow <row /%rowkeywords%/><as400>startcell <cell /%cellkeywords%/><as400>startdata <data type="/%datatype%/" /%datakeywords%/><as400>data /%data%/<as400>enddata </data><as400>endcell </cell><as400>endrow </row><as400>endsheet </worksheet><as400>endbook </workbook></XML>

tx.teatempltSGEN_XL

HSSFCGI Developer Guide

61

perotti
Highlight
Page 62: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

<as400>top<XML> <XLSUPD><as400>cell <cell row="/%row%/" col="/%col%/" /%cellkeywords%/> <data type="/%datatype%/" /%datakeywords%/> /%data%/ </data> </cell><as400>bot </XLSUPD></XML>

XLSUPD_template.txt

HSSFCGI Developer Guide

62

perotti
Highlight
Page 63: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

family accounting

Day Food Clothes Medical Image House Car Vacations Extras Taxes Day total2010-05-01 0 0 0 0 0 0 0 13 0 132010-05-02 13 0 0 0 0 0 0 47 0 602010-05-03 0 0 0 0 0 0 0 0 0 02010-05-04 93 0 4 0 0 0 0 11 0 1082010-05-05 0 0 0 0 0 0 0 3 0 32010-05-06 0 0 0 0 0 0 0 3 0 32010-05-07 14 0 0 0 0 0 0 3 0 172010-05-08 11 0 0 0 0 0 0 3 0 142010-05-09 7 0 0 0 0 0 0 3 0 102010-05-10 2 0 0 0 0 0 0 0 0 22010-05-11 120 0 0 0 0 0 0 3 0 1232010-05-12 0 0 208 0 0 0 0 1 0 2092010-05-13 0 0 5 0 0 0 0 2 0 72010-05-14 10 0 0 0 0 0 0 12 0 222010-05-15 15 0 0 0 0 0 0 3 0 182010-05-16 0 0 0 0 0 0 0 3 0 32010-05-17 11 0 0 0 0 0 0 3 0 142010-05-18 0 0 53 0 0 0 0 3 0 562010-05-19 114 0 0 0 0 214 0 2 0 3302010-05-20 0 0 0 0 0 0 0 0 0 02010-05-21 10 0 0 0 0 0 0 3 0 132010-05-22 17 0 0 0 0 0 0 4 0 212010-05-23 0 0 0 0 0 0 0 60 0 602010-05-24 0 0 0 0 0 0 0 0 0 02010-05-25 4 0 0 0 0 0 0 3 0 72010-05-26 10 0 0 15 0 0 0 8 500 5332010-05-27 0 0 0 0 0 0 51 5 0 562010-05-28 0 0 0 0 0 0 55 23 0 782010-05-29 0 0 0 0 0 0 110 40 0 1502010-05-30 0 0 0 0 0 0 65 2 0 672010-05-31 9 0 0 0 0 0 0 2 0 11

Month total 460 0 270 15 0 214 281 268 500 2.008Daily average 15 0 9 0 0 7 9 9 16 65

Special Formulas --> -80

FAMILY ACCOUNTING

famacc.xls Page 1 of 1

HSSFCGI Developer Guide

63

Page 64: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

Giovanni's Used Boats

36' Solent Spear Year 2005 Current price: £ 155,000 Tax Paid Located in Hamble Point Marina, United Kingdom Hull Material: Fiberglass Engine/Fuel Type: Single Diesel

75' Riva Venere Year 2006 Current price: EUR 2,850,000 Tax Not Paid Located in Located in Liguria, Italy Hull Material: Fiberglass Engine/Fuel Type: Twin Diesel

60' Aprea Mare Year 2006 Current price: US$ 1,565,880 Tax Paid Located in Athens, Greece Hull Material: Fiberglass Engine/Fuel Type: Twin Diesel

GUMB - Giovanni's Used Motor Boats

in November 2016

gub.xls Page 1 of 1

HSSFCGI Developer Guide

64

Page 65: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

Giovanni's Used Boats

39' X-Yachts 412 Year 2002 Current price: EUR 215,000 Tax Paid Located in Bruinisse, Netherlands Hull Material: Fiberglass Engine/Fuel Type: Single diesel

117' Abeking & Rasmussen Classic Yacht Year 1963 Current price: EUR 7,350,000 Tax Not Paid Located in Spain Hull Material: Steel Engine/Fuel Type: Single Diesel

50' Hudson Force 50 Year 1984 Current price: US$ 139,000 Tax Paid Located in Located In Burton, Vashon Island, WA Hull Material: Fiberglass Engine/Fuel Type: Single Diesel

GUSB - Giovanni's Used Sail Boats

in November 2016

gub.xls Page 1 of 1

HSSFCGI Developer Guide

65

Page 66: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

XVSUM example

Family Item 1Q 2Q 3Q 4Q Year totalABC M1V7 312 457 255 523 1.547ABC Q3V2 81 79 102 95 357ABC W3W4 761 684 923 509 2.877

1.154 1.220 1.280 1.127 4.781

CDA J661 1.307 1.702 1.614 1.328 5.951CDA K805 993 1.202 856 897 3.948CDA K822 1.423 1.228 1.235 2.357 6.243CDA K825 911 757 632 805 3.105CDA PW12 775 773 805 667 3.020

5.409 5.662 5.142 6.054 22.267

HEP F51 344 327 313 332 1.316HEP JJA 559 582 577 535 2.253HEP JK7 237 241 229 239 946HEP LL2 127 88 60 74 349

1.267 1.238 1.179 1.180 4.864

7.830 8.120 7.601 8.361 31.912

XVSUM Example

ABC subtotals (from VSUM)

CDA subtotals (from VSUM)

HEP subtotals (from VSUM)

Grand totals (from XVSUM)

xvsumtry.xls Page 1 of 1

HSSFCGI Developer Guide

66

Page 67: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

Catalog

Item No. Description Price (USD)

01BW4 2014 Specialized Tarmac Sport 54cm Carbon Fiber Shimano 105 Road Bike 1.099,99

07LWX Leupold VX-3i 4.5-14x40mm CDS Riflescope Wind-Plex Reticle 170692 424,99

32HF8 HYDRO-FORCE Inflatable Boat Two Person Explorer Raft Set with Paddles and Pump 24,97

PRODUCT CATALOG

catalog.xls Page 1 of 2

HSSFCGI Developer Guide

67

Page 68: HSSFCGI Developer Guide Last modified on January 1, 2021 · 2021. 4. 11. · HSSFCGI A simple way to create Spreadsheets with HSSFR4 by GiovanniB. Perotti(Italy) About it Prerequisites

Catalog

Item No. Description Price (USD)

PRODUCT CATALOG

517YZ Brand New Squash Prince Airstick 130 Racket Racquet Ramy Ashour 120,00

6B9U1 Mini Billiards Pool Ball Set 14,98

catalog.xls Page 2 of 2

HSSFCGI Developer Guide

68