Style Intelligence介绍三 服务器端API

我们可以通过写Java类调用创建的报表模版,动态的填充数据

一 创建模版
打开设计器,创建一个报表
里面只有一个表格,
[img]http://dl.iteye.com/upload/attachment/0075/5135/b86b4fb8-c68e-3b71-8605-0828d0af3e73.jpg[/img]
双击可以查看表格的属性

[img]http://dl.iteye.com/upload/attachment/0075/5137/a595dddb-94c5-368f-9381-42a2d4b323a2.jpg[/img]

写一个Java类

package report;

import inetsoft.report.PreviewView;
import inetsoft.report.Previewer;
import inetsoft.report.ReportSheet;
import inetsoft.report.XSessionManager;
import inetsoft.report.io.Builder;
import inetsoft.report.lens.JDBCTableLens;

import java.io.FileInputStream;

public class Report2 {

public static void main(String[] args) {
try {
//找到报表模版
FileInputStream input = new FileInputStream("D:\\StyleIntelligence Eval\\bin\\template.srt");
Builder builder = Builder.getBuilder(Builder.TEMPLATE, input);
ReportSheet report = builder.read(".");

//数据库连接,查询
JDBCTableLens table = new JDBCTableLens("jdbc:oracle:thin:@127.0.0.1:1521:orcl", "scott","Qwer1234", "select * from emp");
//数据绑定
report.setElement("Table1", table);

//数据展示
PreviewView previewer = Previewer.createPreviewer();
previewer.setExitOnClose(true);

previewer.pack();
previewer.setVisible(true);
previewer.print(report);
} catch (Exception e) {
e.printStackTrace();
}
}

}



运行

[img]http://dl.iteye.com/upload/attachment/0075/5141/40a50c0f-4e63-39ae-8f71-48029a31623e.jpg[/img]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值