• 如何在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中展现的报表来进行打印.

  • 相关阅读:
    day-16 json模块,pickle模块,collections模块,openpyxl模块
    day-15时间模块,datetime模块,random随机模块
    day-5OS与操作系统交互的模块,sys模块,加密模块
    day14内置函数,函数递归,模块
    day13三元表达式,列表生成式,生成器表达式,匿名函数,内置函数
    day13面向过程编程
    day13生成器
    叠加装饰器,
    迭代器
    day11---装饰器
  • 原文地址:https://www.cnblogs.com/shiGuangShiYi/p/10117496.html
Copyright © 2020-2023  润新知