Converting a sample database file to an Excel spreadsheet. (CVTDBFXL)
Convert Database file to Excel (CVTDBFXL) Creating your Excel Report. Scenario: There is an Employee Salaries database file (CS_GLLIB/EMP_SALS). In additional, there are 5 spare fields at the end of this file, to accommodate extra columns created with formulas.
Convert Database file to Excel (CVTDBFXL) Creating your Excel Report. Scenario: An excel spreadsheet is to be produced, incorporating the following :- Sort the report by department and split the report, so each department is in a separatley named worksheet, format the worksheet so that the department is shown in the headers, not as a cell within the detail. Create four new columns for the Full Name, Basic Salary, Overtime Paid and Total Salary. Align columns containing character data, to the left and columns containing numeric data, to the right. Format columns containing numeric data to contain two decimal places. Show a Salary total for each department. Place the company logo on the report. Show the report title on the report. Display the date, worksheet and page numbers within the page footer. Style the column headers and department totals to make them distinctive. Use border styling around the report.
Convert Database file to Excel (CVTDBFXL) Using CoolSpools to produce your report. Before the excel spreadsheet is created, using the CVTDBFXL command, various entities require setting up. Database-to-excel map. Row Groups and Cell definitions. Style definitions.
Convert Database file to Excel (CVTDBFXL) How the database-to-excel map will be constructed. Parent Row Group (Logo, Title and Department) Sub Row Group (Column Headings) Sub Row Group (Data) Sub Row Group (Department totals) Surname Full Name Basic Hrs Worked Hourly Rate First Name Hourly Rate Overtime Hrs Worked CELLS Department Total for Salary CELLS SurnameFull Name Basic Hrs Worked Hourly Rate First Name Hourly Rate Overtime Hrs Worked CELLS
Convert Database file to Excel (CVTDBFXL) Creating the Database file to Excel Map. CRTDBFXL is used to create the map, as follows:- The map is given a name and the database filename, is specified.
Convert Database file to Excel (CVTDBFXL) Adding Row Groups to the Database file to Excel Map. ADDDBFXLR is used to add row groups to the map. This row group ‘NEWSHEET’, will be the controlling parent row group. The New row group rule is set to DEPARTMENT, so the report splits by DEPARMENT.
Convert Database file to Excel (CVTDBFXL) Adding Row Groups to the Database file to Excel Map. If you wish to add Row Groups from the menu, use the command WRKDBFXL. Locate the Database Map created (DEPT_MAP) and use ‘8’ to select Row groups. From that screen you can use F6, to add row groups.
Convert Database file to Excel (CVTDBFXL) Adding Row Groups to the Database file to Excel Map. Another row group is added for the column headers.
Convert Database file to Excel (CVTDBFXL) Adding cells to the COL_HEAD row group. Use ADDDBFXLC to add Map Cells. Now that the row group, for the column headings has been created, the column names are defined. Notice that the content field is set to *TEXT.
Convert Database file to Excel (CVTDBFXL) Adding cells to the COL_HEAD row group. Adding map cells can also be done, by using the menu. Whilst using WRKDBFXL, select the Row group COL_HEAD and enter ‘9’ to goto the map cells section. From here, F6 is used to add new map cells.
Convert Database file to Excel (CVTDBFXL) Adding cells to the COL_HEAD row group. The following cells are added to complete the column headings row group. RowColumnText 1BFirst Name 1CDepartment 1DHourly Rate 1EHours Worked 1FOvertime Worked The cells for the COL_HEAD row group, now looks as follows:-
Convert Database file to Excel (CVTDBFXL) Adding Row Groups to the Database file to Excel Map. Now the column headings are complete, the data line row group is created.
Convert Database file to Excel (CVTDBFXL) Adding cells to the EMP_DETAIL row. Now that the row group, for the data lines has been created, the data fields are to be defined. Notice that the content field is set to *COLUMN.
Convert Database file to Excel (CVTDBFXL) Adding cells to the EMP_DETAIL row group. The following cells are added to complete the EMP_DETAIL row group. RowColumnColumn Name 1BFIRSTNAME 1CDEPARTMENT 1DHOURLYRT 1EHOURSWRKD 1FOVERTIME The cells for the EMP_DETAIL row group, now looks as follows:-
Convert Database file to Excel (CVTDBFXL) Adding Row Groups to the Database file to Excel Map. The last row group to be added, is the end of group row, to show the department total. Notice that the New row group rule is set as DEPARTMENT, so the split by department can be detected. The cells for the total will be added later.
Convert Database file to Excel (CVTDBFXL) Creating the Excel Spreadsheet. The excel spreadsheet is created, using the CVTDBFXL command. The above command creates the following spreadsheet. This is not the finished product, and needs work on the formatting.
Convert Database file to Excel (CVTDBFXL) Formatting the Spreadsheet – One Worksheet per Department. To allow each department to be contained, in a separate worksheet, the CHGDBFXLR command is used to amend the NEWSHEET Row group. An action before each new row group is set. Changing the Row Group can also be done from the WRKDBFXL menu, by locating the Map and using ‘2’ to change the NEWSHEET Row group. The parameters are changed on the second page of the command.
Convert Database file to Excel (CVTDBFXL) Formatting the Spreadsheet – One Worksheet per Department. Now that the before new row group action has been changed, the spreadsheet will be created as follows, one department per worksheet.
Convert Database file to Excel (CVTDBFXL) Formatting the Spreadsheet – Using the Department in the header. As the department is a repeated field, it is logical to take the field out of the data line and put into the header. To do this, the cell is deleted from both the COL_HEAD and EMP_DETAIL row groups. Now a cell is added, to the PARENT row group, NEWSHEET. Text for ‘Department :’
Convert Database file to Excel (CVTDBFXL) Formatting the Spreadsheet – Using the Department in the header. Now a cell is added, to the PARENT row group, NEWSHEET. Data field for ‘Department :’ The title starts on line 4, as there is additional information to be added later. Before the spreadsheet is to be created again, the department title will be assigned a style definition.
Convert Database file to Excel (CVTDBFXL) Formatting the Spreadsheet – Styling the Department Title. Using the command CRTSTLDFN, a new style NEWSHEET is created with the following attributes. FONTNAMEArial FONTSIZE14.00 TEXTCOLOR*WHITE BACKCOLOR*DARKBLUE ROWHEIGHT*AUTOFIT TOPBDR*THIN*BLACK2 BOTTOMBDR *THIN*BLACK2 LEFTBDR *THIN*BLACK2 RIGHTBDR *THIN*BLACK2 All colours for text, backgrounds and borders can be found in the user guides or in the Appendix.
Convert Database file to Excel (CVTDBFXL) Formatting the Spreadsheet – Using the Department in the header. Now the department has been taken out of the COL_HEAD and EMP_DETAIL row groups and added to the PARENT row group NEWSHEET, the spreadsheet created will be as follows.
Convert Database file to Excel (CVTDBFXL) Formatting the Spreadsheet – Adding in extra fields. Now the department has been taken out, column C will be utilised and other columns will be added. The following columns are added. Column C-Full Name. Column G-Basic Salary Paid. Column H-Overtime Payment. Column I-Total Salary. These columns are created from existing fields, using the FORMULA function. Column C-Concatenation of First Name and Last Name. Column G-Hourly Rate multiplied by Hours Worked. Column H-Hourly Rate multiplied by Overtime Hours. Column I-Basic Salary Paid added to Overtime Payment.
Convert Database file to Excel (CVTDBFXL) Formatting the Spreadsheet – Adding in extra fields. Cells are added to the row group COL_HEAD, for the extra columns headings. The ADDDBFXLC command is used to add the new headings. The row group COL_HEAD should now like the this.
Convert Database file to Excel (CVTDBFXL) Formatting the Spreadsheet – Adding in extra fields. Cells are added to the row group EMP_DETAIL for the data columns. Using the ADDDBFXLC command, new data cells are added. Concatenating the First Name and Surname creates the Full Name. Formulas look complicated, but they are quite simple. By specifying INDIRECT....ROW(), each row in treated in turn. Column B is then added ‘&’ to Column A. Thus creating column C.
Convert Database file to Excel (CVTDBFXL) Formatting the Spreadsheet – Adding in extra fields. The Basic Salary Paid column, is created using the formula function, with the ‘*’ symbol, to specify you are multiplying Hourly Rate (D) by the Hours Worked (E). The Overtime Payment column is created in the same way using columns D and F. The Total Salary is calculated by using the ‘+’ symbol to add together Basic Salary Paid (G) and Overtime Payment (H). The row group should now look like this.
Convert Database file to Excel (CVTDBFXL) Formatting the Spreadsheet – Adding in extra fields. Now that extra fields have been added in, the spreadsheet will now look like this. The spreadsheet now has all the columns required, but extra style formatting is still needed.
Convert Database file to Excel (CVTDBFXL) Formatting the Spreadsheet – Creating a Total line for each department. A total for each department is created, again using the formula function. Firstly, a text cell is added for the text literal, ‘Total’. Then, a formula is created to add up all the Basic Salaries (I), for the department. These cells are added to the END_OF_GROUP row group.
Convert Database file to Excel (CVTDBFXL) Formatting the Spreadsheet – Creating a Total line for each department. The spreadsheet now contains a total for each department.
Convert Database file to Excel (CVTDBFXL) Formatting the Spreadsheet – Adding in the Company Logo The top three rows of the spreadsheet were left available, for the company logo and report title. A sample company logo has been stored on the IFS, as a jpeg image. The image is referenced and positioned at the top left of the spreadsheet.
Convert Database file to Excel (CVTDBFXL) Formatting the Spreadsheet – Adding the Report Title The report title is added, spanning the top two rows and positioned at the top right of the report.
Convert Database file to Excel (CVTDBFXL) Formatting the Spreadsheet – Adding the Logo and Report Title Now the company logo and Report title have been added, the NEWSHEET row group should look as follows.
Convert Database file to Excel (CVTDBFXL) Formatting the Spreadsheet – Adding the Logo and Report Title Now the spreadsheet will look as follows.
Convert Database file to Excel (CVTDBFXL) Formatting the Spreadsheet – Setting the column widths. To ensure that the report fits the page, column widths have to be specified. The CVTDBFXL command is changed to add in column width parameters.
Convert Database file to Excel (CVTDBFXL) Formatting the Spreadsheet – Styling the Column Headings. A style definition is created for the COL_HEAD row group, named COL_HEAD, with the following parameters. FONTSIZE(12.00) TEXTCOLOR(*WHITE) BACKCOLOR(*LIGHTBLUE) HRZALIGN(*GENERAL) INDENT(*NONE) VRTALIGN(*TOP) WRAP(*YES) LOCKED(*NO) TOPBDR(*THIN *BLACK 2) BOTTOMBDR(*THIN *BLACK 2) LEFTBDR(*THIN * BLACK 2) RIGHTBDR(*THIN *BLACK 2)
Convert Database file to Excel (CVTDBFXL) Formatting the Spreadsheet – Styling the Title and Column Headings. The spreadsheet will now be created with a formatted Title and Column Headings, but they are not finished.
Convert Database file to Excel (CVTDBFXL) Formatting the Spreadsheet – Applying style formatting to the columns. Rows groups have been allocated style definitions, but to individually style columns, styles need to be applied conditionally. All numeric cells need to be right justified, a style definition right1, is created with the following parameters. FONTSIZE(12) TEXTCOLOR(*WHITE) BACKCOLOR(*LIGHTBLUE) HRZALIGN(*RIGHT) VRTALIGN(*TOP) WRAP(*YES) LOCKED(*NO) TOPBDR(*THIN *BLACK 2) BOTTOMBDR(*THIN *BLACK 2) LEFTBDR(*THIN *BLACK 2) RIGHTBDR(*THIN *BLACK 2) NBRFMT(*CURRENCY 2)
Convert Database file to Excel (CVTDBFXL) Formatting the Spreadsheet – Applying styles with conditional formatting. As different rows require different formatting, within each column, style definitions require setting up and rules defined. For the conditional formatting to be effective, the NEWSHEET and END_OF_GROUP row groups need to be changed. Row Group :NEWSHEET RowColContentColumn Name or Constant Text 1 A *IMAGE *PATH /home/images/company_logo.jpg 1 D *TEXT '.' 1 E *TEXT 'Title' 1-2 F-I *TEXT 'Employee Weekly Salary Report' 2 D *TEXT '.' 2 E *TEXT 'Title' 3 D *TEXT '.' 3 E *TEXT '.' 3 F *TEXT '.‘ 3 G *TEXT '.' 3 H *TEXT '.' 3 I *TEXT '.' 4 A *TEXT 'Department :' 4 B *COLUMN DEPARTMENT 4 C *TEXT '.' 4 D *TEXT '.' 4 E *TEXT '.' 4 F *TEXT '.‘ 4 G *TEXT '.' 4 H *TEXT '.' 4 I*TEXT '.'
Convert Database file to Excel (CVTDBFXL) Formatting the Spreadsheet – Applying styles with conditional formatting. Row Group :END_OF_GROUP RowColContentColumn Name or Constant Text 1 A *TEXT '^' 1 B *TEXT '^' 1 C *TEXT '^' 1 D *TEXT '^' 1 E *TEXT '^' 1 F *TEXT '^' 1 G *TEXT '^' 1 H *TEXT 'Total' 1 I *FORMULA =(SUM(INDIRECT("I6:I"&ROW()-1)))
Convert Database file to Excel (CVTDBFXL) Formatting the Spreadsheet – Additional styles needed for the Conditional Formatting. Style Name :top_border Font Name ARIALFont Size10.00Text Colour*WHITE Background Col.*WHITETop Border *THIN *BLACK 2 Style Name :no_border Font Name ARIAL Font Size10.00 Text Colour *WHITE Background Col. *WHITE Style Name : righte Font Name ARIAL Font Size10.00 Text Colour *BLACK Background Col. *WHITEHRZALGIN*RIGHT VRTALIGN *TOP Right Border *THIN *BLACK 2 NBRFMT*ACCOUNTING 2 *FMT *NONE Style Name : WHITE_CELL Font Name ARIAL Font Size8.00 Text Colour *AUTO Background Col.*WHITEHRZALGIN*RIGHT VRTALIGN *CENTER Right Border*THIN *WHITE 2 Style Name : report_title Font Name ARIAL Font Size16.00 Bold*Yes Text Colour *BLACKBgrd Col.*WHITEHRZALIGN*RIGHT VRTALIGN*CENTER
Convert Database file to Excel (CVTDBFXL) Formatting the Spreadsheet – Additional styles needed for the Conditional Formatting. Style Name :RED_CELL Font Name ARIALFont Size8.00Text Colour*AUTO Background Col.*REDVRTALIGN*CENTER Style Name :total_cell Font Name ARIAL Font Size10.00 Text Colour *BLACK Background Col.*GRAY25 HRZALIGN*RIGHTVRTALIGN*BOTTOM TOPBDR*THIN *BLACK 2BOTTOMBDR*THIN *BLACK 2 LEFTBDR*THIN *BLACK 2RIGHTBDR*THIN *BLACK 2 NBRFMT*ACCOUNTING 2 *FMT *NONE Style Name :EMP_DETAIL Font Name ARIAL Font Size10.00 Text Colour *BLACK LEFTBDR*THIN *BLACK 2RIGHTBDR*THIN *BLACK 2
Convert Database file to Excel (CVTDBFXL) Formatting the Spreadsheet – Applying styles with conditional formatting. With the style definitions created, the following conditional groups and rules need adding to the CVTDBFXL command. GROUPS CNDFMTGRP ((1 COL_A *USED *XLCOLID (A)) (2 COL_B *USED *XLCOLID (B)) (3 COL_C *USED *XLCOLID (C)) (4 COL_D *USED *XLCOLID (D)) (5 COL_E *USED *XLCOLID (E)) (6 COL_F *USED *XLCOLID (F)) (7 COL_G *USED *XLCOLID (G)) (8 COL_H *USED *XLCOLID (H)) (9 COL_I *USED *XLCOLID (I)))
Convert Database file to Excel (CVTDBFXL) Formatting the Spreadsheet – Applying styles with conditional formatting. With the style definitions created, the following conditional groups and rules need adding to the CVTDBFXL command. RULES CNDFMTRULE((1 1 *XLCOLID A *EQ '^' *NONE top_border) (2 1 *XLCOLID B *EQ '^' *NONE top_border) (3 1 *XLCOLID C *EQ '^' *NONE top_border) (3 2 *XLCOLID C *EQ '.' *NONE no_border) (4 1 *XLCOLID D *EQ '^' *NONE top_border) (4 2 *XLCOLID D *BETWEEN righte) (4 3 *XLCOLID D *NE 'Hourly Rate' *NONE WHITE_CELL) (5 1 *XLCOLID E *EQ '^' *NONE top_border) (5 2 *XLCOLID E *BETWEEN righte) (5 3 *XLCOLID E *NE 'Hours Worked' *NONE WHITE_CELL) (6 1 *XLCOLID F *EQ '^' *NONE top_border) (6 2 *XLCOLID F *BETWEEN righte) (6 3 *XLCOLID F *EQ 'Employee Weekly Salary Report' *NONE report_title) (6 4 *XLCOLID F *NE 'Overtime Hours' *NONE WHITE_CELL)
Convert Database file to Excel (CVTDBFXL) Formatting the Spreadsheet – Applying styles with conditional formatting. With the style definitions created, the following conditional groups and rules need adding to the CVTDBFXL command. RULES...continued. CNDFMTRULE(7 1 *XLCOLID G *EQ '^' *NONE top_border) (7 2 *XLCOLID G *BETWEEN righte) (7 3 *XLCOLID G *NE 'Basic Salary Paid' *NONE WHITE_CELL) (8 1 *XLCOLID H *EQ '^' *NONE top_border) (8 2 *XLCOLID H *BETWEEN righte) (8 3 *XLCOLID H *EQ 'Total' *NONE total_cell) (8 4 *XLCOLID H *NE 'Overtime Payment' *NONE WHITE_CELL) (9 1 *XLCOLID I *EQ '^' *NONE top_border) (9 2 *XLCOLID H *EQ 'Total' *NONE total_cell) (9 3 *XLCOLID E *EQ 'Title' *NONE RED_CELL) (9 4 *XLCOLID I *BETWEEN righte) (9 5 *XLCOLID I *NE 'Total Salary' *NONE WHITE_CELL))
Convert Database file to Excel (CVTDBFXL) Formatting the Spreadsheet – Formatting the Footer. The process of completing the spreadsheet is almost finished. To format the footer, include the following within the parameter XLSPRINT for the CVTDBFXL command. Orientation*LANDSCAPE Unit of Measure *MM Left Margin8 Right Margin20 Top Margin1 Page footer left section‘Date : &D’ Page footer center section‘Worksheet : &A’ Page footer right section‘Page : &P of &N’
Convert Database file to Excel (CVTDBFXL) Formatting the Spreadsheet – The full CVTDBFXL command. The completed command used to create the spreadsheet, usually stored in a CL program is shown below. CVTDBFXL FROMFILE(CS_GLLIB/EMP_SALS) STMFOPT(*REPLACE) MAPNAME(DEPARTMENT_MAP) (*YES) HEADER(*AVAIL 0) APYSTYLES((*XLCOLID D right1) (*XLCOLID E right1) (*XLCOLID F right1) (*XLCOLID G right1) (*XLCOLID H right1) (*XLCOLID I right1)) COLWIDTHS((A 18) (B 20) (C 23) (D 9) (E 9) (F 10) (G 14) (H 14) (I 14)) EXCEL(*XLSX *MM *HMS *DFT) XLSPRINT(*NONE *CNTRYID *LANDSCAPE *NO *NONE *MM *DFT *NONE *NONE *NONE 'Date : &D' 'Worksheet : &A' 'Page : &P of &N') CNDFMTGRP((1 COL_A *USED *XLCOLID (A)) (2 COL_B *USED *XLCOLID (B)) (3 COL_C *USED *XLCOLID (C)) (4 COL_D *USED *XLCOLID (D)) (5 COL_E *USED *XLCOLID (E)) (6 COL_F *USED *XLCOLID (F)) (7 COL_G *USED *XLCOLID (G)) (8 COL_H *USED *XLCOLID (H)) (9 COL_I *USED *XLCOLID (I))) CNDFMTRULE((1 1 *XLCOLID A *EQ '^' *NONE top_border) (2 1 *XLCOLID B *EQ '^' *NONE top_border) (3 1 *XLCOLID C *EQ '^' *NONE top_border) (3 2 *XLCOLID C *EQ '.' *NONE no_border) (4 1 *XLCOLID D *EQ '^' *NONE top_border) (4 2 *XLCOLID D *BETWEEN righte) (4 3 *XLCOLID D *NE 'Hourly Rate' *NONE WHITE_CELL) (5 1 *XLCOLID E *EQ '^' *NONE top_border) (5 2 *XLCOLID E *BETWEEN righte) (5 3 *XLCOLID E *NE 'Hours Worked' *NONE WHITE_CELL) (6 1 *XLCOLID F *EQ '^' *NONE top_border) (6 2 *XLCOLID F *BETWEEN righte) (6 3 *XLCOLID F *EQ 'Employee Weekly Salary Report' *NONE report_title)
Convert Database file to Excel (CVTDBFXL) Formatting the Spreadsheet – The full CVTDBFXL command Continued. (6 4 *XLCOLID F *NE 'Overtime Hours' *NONE WHITE_CELL) (7 1 *XLCOLID G *EQ '^' *NONE top_border) (7 2 *XLCOLID G *BETWEEN righte) (7 3 *XLCOLID G *NE 'Basic Salary Paid' *NONE WHITE_CELL) (8 1 *XLCOLID H *EQ '^' *NONE top_border) (8 2 *XLCOLID H *BETWEEN righte) (8 3 *XLCOLID H *EQ 'Total' *NONE total_cell) (8 4 *XLCOLID H *NE 'Overtime Payment' *NONE WHITE_CELL) (9 1 *XLCOLID I *EQ '^' *NONE top_border) (9 2 *XLCOLID H *EQ 'Total' *NONE total_cell) (9 3 *XLCOLID E *EQ 'Title' *NONE RED_CELL) (9 4 *XLCOLID I *BETWEEN righte) (9 5 *XLCOLID I *NE 'Total Salary' *NONE WHITE_CELL)) SORT((DEPARTMENT) (SURNAME) (FIRSTNAME))
Convert Database file to Excel (CVTDBFXL) The completed Spreadsheet. Once everything is setup and the CVTDBFXL command is built, the spreadsheet created will look like this.
Convert Database file to Excel (CVTDBFXL) The completed Spreadsheet – Print Preview This is how the spreadsheet will look when printed.
Convert Database file to Excel (CVTDBFXL) Appendix. Colour Chart for use when styling.