Getting Started with Eclipse Birt Report development

Source: Internet
Author: User

In development, reports are more or less involved, some reports may be simpler, and some reports may be complex. In any case, the development of these reporting functions can be achieved through a number of public components, such as I am now in the company, if you want to make a report, only need to configure under the report configuration (this report is implemented in a specific report language implementation, support the internal customization of the language, Finally, these corresponding data are saved to the database, some things in the report are abstracted, such as: report model, query parameters. )。 If you want to write your own manual step-by-step report, then it is relatively troublesome, if you can provide a framework, only need to do some configuration to complete the custom report, it is not very easy. Now the popular report framework is still quite a lot, because the company is using Eclipse's Birt report, all this article simply introduces the use of the Birt reporting framework.

1. Birt Download and install

Download Birt:

As: http://download.eclipse.org/birt/downloads/, for example, directly click on "Download Now" to download, it is recommended to download the All-in-one version (this is actually an eclipse, It contains the Birt report plug-in) so that you do not need to install the Birt plugin for Eclipse, which is very convenient, but also to avoid the installation of Birt plug-ins in eclipse a variety of problems, because bloggers I am lazy, my eclipse is All-in-one version.


With the Birt plug-in installation, this is relatively cumbersome if you do not use the Eclipse plug-in installation online, because the dependent plug-ins of the Birt plug-in are installed (though you can download eclipse with the integrated WPT, the installation is relatively less dependent).


Offline installation ECLISPE plug-ins are common in 2 ways: One is the link method (this is relatively flexible), and the second is to copy to the corresponding directory of the way to install. (This article does not introduce the offline installation method, the need can be self-Baidu) This article mainly said on-line installation method:

1. Click Help--->install New software


2. Enter the URL, make some tick, then select Next

The above URL can be found in this address Http://wiki.eclipse.org/BIRT_Update_Site_URL, select the appropriate version of the URL is ok, but as long as 3.7.x(including) and the above version of the URL address is valid, The other addresses are useless.


There are a few more steps left to omit, just click Next, agree to the agreement, and then wait for the installation to complete before restarting Eclipse.

The ability to switch to the report view indicates that the installation was successful and the installation at this point is Birt.


2.birt Development Examples

Note: This article is only for Eclispe Birt official provided example of a transport, English better children's shoes can go directly to the official website to see, address: http://www.eclipse.org/birt/documentation/tutorial/ Tutorial-2.php, this example makes a BIRT report to display the information of the customer (Customers). Subsequent Birt articles will give some more meaningful examples of Birt development.

1. Start a new report Project project, and in the workspace right-click new->project-> Select the "Report Project" under the "Business Intelligence and Reporting Tools" node Click "Next", enter the project name: My project, click "Finish", then the item has been created, a dialog box asks if you open the associated View (report view), click "Yes" to enter the report view, Appears as indicated that the project has been created successfully.

2. Create a report

Right-click My Project project, new, and report, enter the file name: customers.rptdesign (rptdesign suffix birt reporting file), tap Next, and then select grouped Listing (a list template with grouped work), and then tap Finish to switch to report view.


The following is a simple introduction to the various views (view) function:

(1) Palette (color palette)-This view is a common component that can be dragged to a report

(2) Data Explorer-this view is used to display the data source (data Sources), the dataset (sets), and the Reporting parameters (report parameters). You can also use this view to add columns of data sets to the report layout.

(3) Resource Explorer (Explorer)--In this view you can see all the report related resources, for example: Birt report file

(4) Property Editor--This view contains some of the properties of the report, and you can take a good look at it when needed.

3. Build a data source

A data source represents the source of the obtained data, either JDBC,ODBC or an XML file, in general, where the data comes from.

Switch to the Data Explorer view, select "Data Sources", right click on it, and click "New Data Source" in the context menu.

The New Data Source dialog box appears, select the Classic Models INC sample Database (This is the example Birt provided), and then enter the name of the data source: Sample, click Next, then click Finish, Then a data source is created.


If you want to modify the data source, then directly click on the corresponding data source, the above example, you can double-click "Sample" to modify it, so far the data source creation is complete. Now that we have the data source, but only the data source is not good, it is only used to provide data, if you want to obtain data, then also need to create a dataset, he used to obtain data information.

4. Creating datasets (Data Set)

    • Switch to Data Explorer view, right-click "Data Sets", in the right-click menu that appears, select "New Data Set", "New Data Set" dialog box appears
    • Select the "Sample" data source you just created, select "Data Set Type": SQL select Query, enter "Data set Name": Customer
    • Click Next
    • Input query statement: SELECT *
      From
      Customers
      where
      Country = ' USA '
    • Click Finish

When you click "Finish", the DataSet Edit dialog box appears, which provides the following pages:

    • The data source---shows the datasource used by the dataset, and you can change it

    • Query-can be used to view and edit queries, you can view the database and tables in the "Available Items"

    • Output Columns--The column displayed in the query statement, you can alias the column.
    • Computed Columns--computed columns, followed by other column types
    • Parameters--These parameters can be included in the query statement and filtered according to the conditions
    • Filters-Filter the query results
    • Preview Results--previews of results from previous query statements

Now that you have the dataset, you need to show the data to the table.

5. Populating the table

    • Open the Data Explorer view, select the "CUSTOMERNAME" under the "Customer" node under the "Data sets" node, and drag it to the second column in the table with the gray font "Detail row" (that is, the second column in the third row)


    • After dragging past, such as:


    • Create a state group (we want to place customers of the same state together and need to sort by state)
      • Navigate to the group Header row in the table (identified by a gray font) and the row (that is, the second row),
      • Drag the state to the first column of the first row of the group Header row in the table (the first column in the second row)


After dragging the state line over:


    • Create a city group manually
  • Mouse over the table, there is a table hover box, and then click the Hover box, select the entire table


The following graphic appears:


  • Switch to the Property editor view and switch to the Binding tab bar

    • Then click the "Add" button, the "New Date Binding" dialog box appears, enter the column binding Name:city,display name:city, click the "FX" button at the end of the expression column, BIRT The Expression Builder dialog box appears

    • In the Expression Builder dialog box, select "Available Data Sets" in category, select "Customer" in sub-category, double click on "Double click to insert" "City" column, then click "OK"

    • Go back to the "New Data Binding" dialog and click "OK"

    • Make the table Select all, then right-click the gray hover cell above the "state" header, and in the context menu that appears, Insert Group---Below, the New Group dialog box appears

    • In the New Group dialog box, enter Name:city, select City in Group on, and then click OK

    • Add a column to the table, select the table, right-click in the gray cell above the "state" header, and the right-click menu, choose Insert-and-column to-the-button (equivalent to inserting a second column in the table)

    • Move the city Data element (the group header in the second group of the first column) to the group header of the second group of the second column (that is, move to the second column in the third row)

Drag it over and it looks like this:

    • Create or modify a table header (we may need to make some adjustments to the table header)
      • Double-click the header of the first column to modify it to: state

      • In the Palette view, drag a label to the second row of the table header, and enter city

      • Double-click the third column of the header "CUSTOMERNAME" and modify it to "Name"
      • Add the last Header "phone", and in the Data explorer view, drag the date sets-> Customer-PHONE to the last column on line fourth, then double-click it to change it to "phone"

      • This is done after the modification:

    • Finally, click the Save button to save the file.
6. Preview your report
    • You can preview the report you've designed by using the Report Designer's Preview tab, and then I'm not looking for a tab bar (specifically why I'm not going to go into it here), and I'll do another way to preview the report.

    • Preview the report from the toolbar's view reports, click This will appear a list of options, you can choose an HTML format preview, PDF Preview, there are many can choose


Here is the result of the report preview (more detailed report details, please do it yourself, see the results):

At this time we generated the report has been able to display, but not good-looking, it needs to be typeset, the following is some typesetting ~ ~ ~

The next layout please do your own, typesetting I will no longer explain


Getting Started with Eclipse Birt Report development

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.