Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource (usually a database connection).
Jaspersoft Studio是Eclipse的插件,可让您从数据源(通常是数据库连接)创建报告。
Here's their website with further information about Jaspersoft Studio:
这是他们的网站,其中包含有关Jaspersoft Studio的更多信息:
https://community.jaspersoft.com/project/jaspersoft-studio
https://community.jaspersoft.com/project/jaspersoft-studio
In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
在本文中,我们将介绍从默认模板创建报告并设置连接到数据库的数据源。
Before we get started you'll need a couple things:
在我们开始之前,您需要注意以下几点:
- Eclipse 蚀
- Jaspersoft Studio Eclipse Plugin Jaspersoft Studio Eclipse插件
- A database (I'll be using Oracle as an example, but it supports any JDBC connection) 数据库(我将以Oracle为例,但它支持任何JDBC连接)
To install the Jaspersoft Studio plugin you'll need to follow these steps:
要安装Jaspersoft Studio插件,您需要执行以下步骤:
- Open Eclipse 打开Eclipse
- Click Help 点击帮助
- Click on "Install New Software..." in the drop down menu 在下拉菜单中单击“安装新软件...”
- Enter "http://jasperstudio.sourceforge.net/updates/" without quotes into the "Work with:" field 在“使用方式:”字段中输入不带引号的“ http://jasperstudio.sourceforge.net/updates/”
Select the main checkbox for "Business Intelligence, Reporting Tools" which should check all the checkboxes for that category
The current version of Jaspersoft Studio is "5.6.2.final"选中“商务智能,报告工具”的主要复选框,该复选框应选中该类别的所有复选框
Jaspersoft Studio的当前版本是“ 5.6.2.final”- Click Next 点击下一步
- Accept the license agreements (after reading) and complete the installation 接受许可协议(阅读后)并完成安装
- Eclipse will need to restart Eclipse将需要重新启动
Now that we have the Report Design perspective we can create our datasource. There should be two tabs in the top left pane called "Repository Explorer" and "Project Explorer." First, select the "Repository Explorer" tab and then:
现在我们有了“报表设计”透视图,可以创建数据源了。 左上方窗格中应有两个选项卡,分别是“资源库资源管理器”和“项目资源管理器”。 首先,选择“资源库浏览器”选项卡,然后:
- Right click on "Data Adapters" and choose "Create Data Adapter" 右键单击“数据适配器”,然后选择“创建数据适配器”
A window will popup, for connecting to a database select "Database JDBC Connection"
and click next.
All the options in that list are available data adapters, but for the purposes of this article we're only creating a database connection.将弹出一个窗口,用于连接数据库,选择“数据库JDBC连接”
然后单击下一步。
该列表中的所有选项都是可用的数据适配器,但是出于本文的目的,我们仅创建数据库连接。Name the data adapter and choose what driver you want to use. I'm using Oracle so I need to choose "Oracle (oracle.jdbc.driver.Oracle
Driver)" 命名数据适配器,然后选择要使用的驱动程序。 我使用的是Oracle,因此需要选择“ Oracle(oracle.jdbc.driver.Oracle
司机)”Now enter the connection string, by default it will have "jdbc:oracle:thin:@localho
st:1521:da tabase" (if you chose Oracle) 现在输入连接字符串,默认情况下它将具有“ jdbc:oracle:thin:@localho
st:1521:da tabase”(如果您选择了Oracle)- Enter the username and password you want to use (note that if you save the password it will be saved in clear text) 输入您要使用的用户名和密码(请注意,如果您保存密码,密码将以明文形式保存)
- Click "Test" to make sure your connection works. If it doesn't you might have entered the connection or user info incorrectly. If it's correct then make sure you can connect to your database from the machine you are running eclipse from. 点击“测试”以确保您的连接正常。 如果不是,则可能输入了错误的连接或用户信息。 如果正确,请确保可以从运行eclipse的计算机连接到数据库。
- Click finish to save the data adapter 单击完成以保存数据适配器
Click File, New, "Jasper Report"
If that option doesn't show up, click "Other," scroll down the list to the folder called "Jaspersoft Studio," choose "Jasper Report" and click Next.单击文件,新建,“碧玉报告”
如果未显示该选项,请单击“其他”,将列表向下滚动到名为“ Jaspersoft Studio”的文件夹,选择“ Jasper Report”,然后单击“下一步”。- Now choose a template from the list and click Next. The "Simple Blue" template is a nice basic one to start with. 现在,从列表中选择一个模板,然后单击“下一步”。 “ Simple Blue”模板是一个很好的基础模板。
- Choose where to save the report and a name for the file, then click Next. 选择保存报告的位置和文件名,然后单击“下一步”。
- If you have a database query ready choose your data adapter from the drop down list and enter your query, then click Next. If you don't have a query you can also do this later, just click Next and you're done! 如果您准备好进行数据库查询,请从下拉列表中选择数据适配器并输入查询,然后单击“下一步”。 如果您没有查询,也可以稍后再执行,只需单击“下一步”就可以了!
- If you entered a query now you have to option to auto create fields (each column of the query is called a field Jasper). Choose the fields you want the report to use and click the ">" button to select them, or click ">>" to select them all. Click Next to continue. 如果现在输入查询,则必须选择自动创建字段(查询的每一列都称为字段Jasper)。 选择您要报告使用的字段,然后单击“>”按钮将其选中,或单击“ >>”将其全部选中。 单击下一步继续。
- If you want to group your data by any of the fields you can select them the same way here. This is mostly useful if you plan on doing calculations on groups of data (for example, doing a distinct count on customers for each day). If you aren't sure if you need a group you can always do this later by right clicking on the report. 如果要按任何字段对数据进行分组,则可以在此处以相同的方式选择它们。 如果您打算对数据组进行计算(例如,每天对客户进行不同的计数),这将非常有用。 如果不确定是否需要一个组,则以后可以随时通过右键单击报告来执行此操作。
- After clicking Next it brings you to the last page saying "Congratulations!" You can either go back to make changes, or click Finish to create your report. 单击“下一步”后,将带您到最后一页,显示“恭喜!” 您可以返回进行更改,也可以单击“完成”创建报告。
After you get more familiar with the software I'd recommend doing some research on using groups, parameters, and variables.
在您对该软件更加熟悉之后,我建议您对使用组,参数和变量进行一些研究。