forked from demo/example
36 lines
1.2 KiB
36 lines
1.2 KiB
6 years ago
|
package com.fr.io;
|
||
|
|
||
|
import com.fr.base.Parameter;
|
||
|
import com.fr.main.TemplateWorkBook;
|
||
|
import com.fr.print.PrintUtils;
|
||
|
import com.fr.workspace.simple.SimpleWork;
|
||
|
|
||
|
import java.util.HashMap;
|
||
|
|
||
|
|
||
|
public class JavaPrint {
|
||
|
public static void main(String[] args) {
|
||
|
// 定义报表运行环境,才能执行报表
|
||
|
String envPath = "D:\\FineReport\\develop\\code\\build\\package\\WebReport\\WEB-INF";
|
||
|
SimpleWork.checkIn(envPath);
|
||
|
try {
|
||
|
TemplateWorkBook workbook = TemplateWorkBookIO.readTemplateWorkBook("GettingStarted.cpt");
|
||
|
// 参数传值
|
||
|
Parameter[] parameters = workbook.getParameters();
|
||
|
HashMap<String, String> paraMap = new HashMap<String, String>();
|
||
|
paraMap.put(parameters[0].getName(), "华北");
|
||
|
|
||
|
// java中调用报表打印方法
|
||
|
boolean a = PrintUtils.printWorkBook("GettingStarted.cpt", paraMap, true);
|
||
|
if (a == false) {
|
||
|
System.out.println("失败啦!返回" + a);
|
||
|
} else {
|
||
|
System.out.println("成功!返回" + a);
|
||
|
}
|
||
|
} catch (Exception e) {
|
||
|
e.printStackTrace();
|
||
|
} finally {
|
||
|
SimpleWork.checkOut();
|
||
|
}
|
||
|
}
|
||
|
}
|