如何在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中展現的報表來進行打印.
轉載于:https://www.cnblogs.com/shiGuangShiYi/p/10117496.html
總結
以上是生活随笔為你收集整理的如何在C/S下打印报表的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Spring MVC的异步模式Deffe
- 下一篇: 关于面向过程编程的一些思考