帆软帮助文档代码合集。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

36 lines
1.2 KiB

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();
}
}
}