如何在C/S下打印报表



java应用有不少是C/S模式,在C/S模式下,同样可以调用API接口运算报表。CSReport是C/S模式下的报表控件类,在这个类中可以获得报表的显示面板、获得报表的打印面板、显示报表打印窗口、直接打印报表等等。

我们来看一下示例代码:

import javax.swing.JFrame;

import com.runqian.report4.model.ReportDefine;
import com.runqian.report4.usermodel.CSReport;
import com.runqian.report4.usermodel.Context;
import com.runqian.report4.usermodel.Engine;
import com.runqian.report4.usermodel.IReport;
import com.runqian.report4.util.ReportUtils;
import com.runqian.report4.util.ReportUtils2;


public class CsPrint {

/**
* @param args
* @throws Throwable
*/
public static void main(String[] args) throws Throwable {
// 读取报表模版的定义
ReportDefine rd = (ReportDefine)ReportUtils.read(“c://a.raq”);
//创建上下文环境
Context ctx = new Context();
//加载引擎
Engine e = new Engine(rd, ctx);
//计算报表
IReport ir = e.calc();
//创建CS报表对象
CSReport csr = new CSReport(ir);
//CS中报表的swing界面的设置等等,需要客户自行根据实际情况完成
JFrame j = new JFrame();
//打印报表
csr.print(j);
//如果是普通的BS结构,可以按照下面的方法来进行打印

/**
* ReportUtils2类:
* 将报表发送到打印机进行打印
* @param report 要打印的报表
* @param needSelectPrinter 是否需要选择打印机
* @throws java.lang.Exception
*/
ReportUtils2.print(ir, true);
}

}

我们可以根据上述的代码,对CS中展现的报表来进行打印.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值