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. 

Begin by creating a new report template named EmployeeInformation, then hide 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 to view the Schema list.

12. 

Click the public schema name to display the public schema's tables.

13. 

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

14. 

Double-click the employee table name.

15. 

Note: The employee table appears with all fields selected by default.

16. 

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

 

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

17. 

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

18. 

Click the OK button to save changes and exit the query designer.

19. 

Click the Next button to move to step 3.

20. 

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.

21. 

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

22. 

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

23. 

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

24. 

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

25. 

Expand the Table Dataset node.

26. 

Expand the dataset's Fields node.

27. 

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

28. 

Click to collapse the Table Dataset node.

29. 

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

30. 

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.

31. 

Note: The Table wizard appears.

32. 

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

33. 

Click the Next button.

34. 

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

35. 

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

36. 

Click the Next button.

37. 

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.

38. 

Click the Next button.

39. 

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

40. 

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

41. 

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

42. 

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. Edit column labels and format the field expressions to your liking.

43. 

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.

44. 

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

45. 

Note: This pane displays the report bands.

46. 

Resize the Table component so it fills the Summary band.

47. 

Click the Table 1 tab to return to table layout view.

48. 

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

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

49. 

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.

50. 

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.

51. 

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

52. 

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

53. 

Click the Group selected columns menu item.

54. 

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

55. 

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

56. 

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.

57. 

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

58. 

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

59. 

Right-click the Column 1 tree item.

60. 

Click the Delete cell menu item.

61. 

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.

62. 

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

63. 

Click the Add cell menu item.

64. 

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.

65. 

Now, repeat steps 50 to 64 to configure the group header above columns 5-7.

66. 

Right-click the Column 7 tree item.

67. 

Click the Group selected columns menu.

68. 

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

69. 

Press the [Ctrl] key and click the Column 7 tree item.

70. 

Right-click the Column 7 tree item.

71. 

Point to the Group selected columns menu.

72. 

Point to the Delete cell menu.

73. 

Click the Delete cell menu.

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. 

Next, drag a Static Text element into the white space of the first group header and configure a label.

 

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 (http://www.jaspersoft.com/scorm_data/DevelopingReportsiReport_6989/data/execute) 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 for the other column group header.

 

Repeat steps 67 to 70 to drag a Static Text element into the second group header and format it to match the first.

82. 

Note: Both labels are formatted to your liking.

83. 

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.

84. 

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

 

Task 2: Configure a Table component, is complete.

85. 

Next, add a title to the report.

 

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

86. 

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

87. 

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

88. 

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

89. 

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.

90. 

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 (http://www.jaspersoft.com/scorm_data/DevelopingReportsiReport_6989/data/execute) course to learn more!

End of Procedure.