### Inserting a table

To insert a table into a report, you can use either of the following methods:

- Using dialog
  1. Position the mouse pointer at the destination where you want to insert the table. A table can be inserted in the report areas listed in Component placement.
  2. Do one of the following to open the Create Table wizard:
     - Click Insert > Table on the menu bar.
     - Click the Insert Table button on the Insert toolbar.
  3. In the Data screen of the wizard, select the dataset on which the table will be created.
     - New
       If checked, the table will be built on a new dataset created from the catalog resources.
     - Existing
       If checked, specify the dataset in the current report set from which the table will be created.
     - Current
       If checked, the table will be built on the dataset which is used by its parent.
  4. In the Display screen, add the required fields from the Resources panel to be displayed in the table. Modify the display name of any added field if required by double-clicking its Display Name column. And if required, click the Sort Fields by button to specify how to sort data in the table.
  5. In the Group screen, add the fields as the grouping criteria, and then specify the sorting direction of each group level in the Sort column.
  6. To add summaries, go to the Summary screen.

     In the sum on panel (the panel on the right), specify the group to which the summary will be applied (if you select Table, the summary will be based on the whole dataset), add a field from the Resources panel as the sum on field, and then select the function for the summary from the Aggregate Function column.

     Notes:

     - The Break Field is a defined field on which the summary will be calculated (if the break field of a summary field is null, the summary will be calculated based on the whole dataset).
     - When the table is created, JReport will automatically give the summaries some proper name labels to help you clarify the meaning of the numbers. The auto generated labels are controlled by the Text property in the Report Inspector. You can manually input the text of the label according to your requirements.
     - If you have created several summaries in the table and the summaries have the same function, by default they will be aligned horizontally in the report, However, you can choose to align them vertically by checking Align summaries vertically in the Options dialog (File > Options > Component > Align summaries vertically).
  7. In the Filter screen, define some filter condition(s) to filter the data displayed in the table.
  8. In the Style screen, specify the style of the table as required.

     If you have specified to insert the table into a banded object, by default the table will inherit its parent's style. If you want to apply another style to the table, uncheck the Inherit Style option and then select the required style from the Style box. For more information, see Inheriting the style from a data container.

  9. Click Finish to insert the table.

     If you have specified to insert the table in the report body, the table will be inserted there upon clicking the Finish button; otherwise, click the mouse button in the location to insert the table.

- By dragging and dropping
  1. From the Toolbox panel, drag Table or Horizontal Table to the destination in the report where allows the insertion of a table, and a blank table will then be created.
  2. In the Resource View panel, select the dataset you want to use in the table from the dataset drop-down list. If you want to create a new dataset for the table, select <Choose Data from...> from the list and new a dataset in the New Dataset dialog as required.
  3. Drag the required fields in the specified dataset from the Resource View panel to the table cells.

     If you drag the field to a cell, it will be added to the cell; if you drag it to the boundary of a cell, the field will be added to the table as a new column/row; if you drag the field at the header of the table detail panel (TD), it will be added as a group level.

After a table has been created, you can customize its appearance and behavior by setting properties in the Report Inspector, which can be saved as a CSS style for future use (for details, see Creating a CSS style).