zoukankan      html  css  js  c++  java
  • 如何在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中展现的报表来进行打印.

  • 相关阅读:
    php 实现四种排序两种查找
    GIT常用命令
    2016-the brave never die
    Apache 的ab压力测试工具
    SQL语句优化实践
    C#设计模式:访问者模式(Vistor Pattern)
    泛型反射性能优化
    C#GC垃圾回收和析构函数和IDisposable的使用
    C#配合大数据开发,nest.dll的使用
    C#导出大量数据到excel,怎么提升性能
  • 原文地址:https://www.cnblogs.com/shiGuangShiYi/p/10117496.html
Copyright © 2011-2022 走看看