Configuring the iReport Table Component Activity

 

 

 

Step

Action

1. 

Activity End Result

At the end of this activity, the Table component is configured and formatted in a report, as displayed above. The report displays employees' personal and professional information under two headers labeled Personal and Company. To accomplish this you configure a dataset that retrieves seven fields from the employee table, then configure the Table component to use that dataset in a report.

2. 

Use the knowledge you gained in previous lab activities to create a new report template named EmployeeInformation to be saved to you Lab Work folder. Then hide (delete) all its bands but Title and Summary.

3. 

The Table component in a report displays data provided by a secondary dataset.

 

At the top of the Report Inspector, right-click the EmployeeInformation node.

4. 

Click the Add Dataset menu item.

5. 

Note: The New Dataset wizard appears.

6. 

Name the dataset.

Enter Table Dataset into the Dataset name field.

7. 

Click the Next button to advance to step 2 of the wizard.

8. 

Note: The data source configured for iReport is the Jaspersoft sample data source called foodmart. The foodmart data source is selected automatically in the wizard.

9. 

Click the Design query button to open the query designer.

10. 

Note: The query designer opens.

11. 

Click the Schema filter drop-down to view the Schema list.

12. 

Click the public list item.

13. 

Note: A list of all the tables in the foodmart public schema appears.

14. 

Note: The desired report displays personal and company information about employees. Only the employee table has this information.

15. 

Double-click the employee list item to add that table to the query.

16. 

Note: The employee table field names are displayed and automatically selected by default. The query is automatically built and displayed in the pane at the upper left.

17. 

The report needs personal information provided by four fields and professional information provided by three.

 

Deselect field names so that only the following seven field names remain selected: first_name, last_name, position_title, hire_date, salary, education_level, and marital_status.

18. 

Note: The seven fields required by the table report are selected.

19. 

Click the OK button to save the query and return to the Report query window.

20. 

Note: The wizard returns to the Report query window and displays the completed query.

21. 

Click the Next button to move to step 3.

22. 

All seven field alias names are preceded by their table name.

 

Click the double-arrow button to move all seven field names to the selection pane.

23. 

Note: The query returned seven fields, and all of them are now available for the Table component.

24. 

Click the Next button to move to step 4 of the wizard.

25. 

Grouping is not required, so click the Finish button to save the dataset configuration and exit the wizard.

26. 

Note: The new dataset, titled Table Dataset, appears in the Report Inspector.

27. 

Expand the Table Dataset node.

28. 

Expand the dataset's Fields node.

29. 

Note: The seven fields you selected are found here and available for use.

30. 

Click to collapse the Table Dataset node.

31. 

Note: Task 1: Configure a dataset, is complete.

32. 

Next, drag a Table component into the Summary band and configure it.

 

Click and drag the Table component into the top-left corner of the Summary band.

33. 

Note: The Table wizard appears.

34. 

Note: The wizard automatically selects the new dataset, so you see Table Dataset displayed in the top field.

35. 

Click the Next button.

36. 

Click the double arrow button to move all the dataset's field names into the selection pane.

37. 

Note: All fields in right-side pane display in the report.

38. 

Click the Next button.

39. 

Note: The Table component uses the report's JDBC connection to the foodmart database, so the default selection at the top of the window is correct.

40. 

Click the Next button.

41. 

In the top section of the wizard's last page you can specify the color scheme and cell border style.

 

Perform the following near the top of the window:

a. Check the box for Create a new set of styles for this table

b. Select a color scheme and variation

c. Check the box for Use alternated detail rows background

42. 

You can specify border information, and configure headers and footers to appear in the report.

 

Lower on the page, make these selections:

a. Select a matching cell border color

b. Click the middle button of the three border styles

c. At the bottom, select only Add Table Header and Add Column Header

43. 

Click the Finish button to accept the selected settings, save the Table component configuration, and exit the wizard.

44. 

Note: The table layout appears in the report design area. The table includes columns for first name, last name, education level, marital status, position title, hire date, and salary.

45. 

Note: The table layout appears in a pane that opens by clicking the Table 1 tab in the lower-left corner of the design area.

46. 

Click the Main report tab in the lower-left corner of the center window to view the Table component in the Summary band.

47. 

Note: This pane displays the report bands.

48. 

Change the height of the Summary band to 80, then resize the Table component so it fills the Summary band.

49. 

Click the Table 1 tab in the lower-left corner of the center window to return to table layout view.

50. 

Edit the column headers to reflect the following user-friendly labels:

First, Last, Title, Hired, Salary,  Education and Status.

51. 

Note: The seven column labels are more user friendly. Labels in the Table component are edited and formatted the same way as in non-table reports.

52. 

Now, create the column group header labeled Personal. This header text appears centered above the first four columns.

 

Expand Summary > Table > Table Header in the Report Inspector.

53. 

Ctrl- or Shift-click to select Column 1 through Column 4.

54. 

Right-click the Column 1 tree item to view the context menu.

55. 

Click the Group selected columns menu item.

56. 

Note: The new Columns 1-4 node indicates that the first four columns are grouped.

57. 

Note: A colored bar spans the four columns in the design area, indicating they are grouped together.

58. 

Note: Although you cannot see them, each of the seven columns has a header space at the top.

 

The first four column headers will be deleted and replaced with one header that spans all four columns. Later the same is done for the remaining three column headers.

59. 

Expand the Columns 1-4 node in the Report Inspector.

60. 

Ctrl- or Shift-click to select Column 1 through Column 4.

61. 

Right-click the Column 1 tree item.

62. 

Click the Delete cell menu item.

63. 

Note: The white header space above the four columns in the design area is gone, to be replaced with a single four-column-wide header.

64. 

In the Report Inspector, right-click the Column 1 (Empty Group Header) tree item.

65. 

Click the Add cell menu item.

66. 

Note: A single header now spans the first four columns. It becomes more visible after you define the second header to span the remaining three columns.

67. 

You will repeat the previous steps to configure the group header above columns 5-7, in the steps that follow.

68. 

Ctrl- or Shift-click to select Column 5 through Column 7.

69. 

Click the Group selected columns menu.

70. 

Click the + button before the Columns 5-7 tree item.

71. 

Ctrl- or Shift-click to select Column 5 though Column 7.

72. 

Right-click the Column 7 tree item.

73. 

Click the Delete cell menu item.

74. 

Right-click the Column 5 (Empty Group Header) tree item.

75. 

Click the Add cell menu.

76. 

Note: At the top of the report in the design area, spaces for the two group headers are defined, separated by a vertical divider.

77. 

Click and drag a Static Text element from the Palette to the group header above the first four columns.

78. 

Note: iReport automatically expands the Static Text element to fill the cell.

79. 

Enter Personal into the field.

80. 

Format the group label.

 

Note: See the Working With Text Fields module for details on resizing and aligning labels.

 

Make the label bigger, center and underline it, and color it to your liking. 

81. 

Add and format a Static Text label containing the text "Company" for the other column group header.

 

Repeat some previous steps to accomplish this.

82. 

Note: Both labels are formatted to your liking.

83. 

Click the Query button to add a query.

84. 

Click the Query Designer button.

85. 

Click the Schema Filter drop-down to view the Schema list.

86. 

Click the Public node.

87. 

Double click the Employee table to add it to the query.

88. 

In the Employee table, make sure that only these seven fields are selected: first_name, last_name, position_title, hire_date, salary, education_level and marital_status.

89. 

Click the OK button to close the Query Designer.

90. 

Click the OK button in the right center of the Query Report window to save the query.

91. 

Now, click the Preview button to preview the report, then return to design mode to adjust the width of columns that need to be narrower or wider. Repeat until the report's appearance meets your needs.

92. 

Note: The column labels and fields are resized and formatted.

 

Task 2: Configure a Table component, is complete.

93. 

Next, add a title to the report.

 

Click the Main report tab at the lower left to view the report bands.

94. 

Now, click and drag a Static Text element into the Title band.

95. 

Edit the title to Current Employee Information, and size/center/color it to your taste.

96. 

Finally, click the Preview button to execute the report and make sure it runs well.

97. 

Note: The report executes and displays two group labels along with the seven column headers and data fields.

 

Task 3: Add a title and preview the report, is complete.

98. 

Click the Save button in the upper left to save this report to the repository

99. 

Congratulations!

 

You completed the following three tasks:

 

1. Configure a dataset to make seven database fields available

2. Configure a Table component that uses the new dataset in a report

3. Add a title and preview the report

 

Note: Take the full Developing Reports with iReport course to learn more!

End of Procedure.