forked from demo/example
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.
49 lines
2.0 KiB
49 lines
2.0 KiB
6 years ago
|
package com.fr.io;
|
||
|
import com.fr.base.Parameter;
|
||
6 years ago
|
import com.fr.config.activator.BaseDBActivator;
|
||
|
import com.fr.config.activator.ConfigurationActivator;
|
||
|
import com.fr.data.impl.config.activator.RestrictionActivator;
|
||
6 years ago
|
import com.fr.main.TemplateWorkBook;
|
||
6 years ago
|
import com.fr.module.Module;
|
||
|
import com.fr.module.tool.ActivatorToolBox;
|
||
6 years ago
|
import com.fr.print.PrintUtils;
|
||
6 years ago
|
import com.fr.report.ReportActivator;
|
||
|
import com.fr.report.module.ReportBaseActivator;
|
||
|
import com.fr.store.StateServerActivator;
|
||
6 years ago
|
import com.fr.workspace.simple.SimpleWork;
|
||
|
import java.util.HashMap;
|
||
|
|
||
|
public class JavaPrint {
|
||
|
public static void main(String[] args) {
|
||
6 years ago
|
// 首先需要定义执行所在的环境,这样才能正确读取数据库信息
|
||
|
// 定义报表运行环境,用于执行报表
|
||
6 years ago
|
Module module = ActivatorToolBox.simpleLink(new BaseDBActivator(),
|
||
|
new ConfigurationActivator(),
|
||
|
new StateServerActivator(),
|
||
|
new ReportBaseActivator(),
|
||
|
new RestrictionActivator(),
|
||
|
new ReportActivator());
|
||
6 years ago
|
String envpath;//工程路径
|
||
|
envpath = "//Applications//FineReport10_325//webapps//webroot//WEB-INF";
|
||
|
SimpleWork.checkIn(envpath);
|
||
6 years ago
|
module.start();
|
||
6 years ago
|
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);
|
||
6 years ago
|
if (!a) {
|
||
6 years ago
|
System.out.println("失败啦!返回" + a);
|
||
|
} else {
|
||
|
System.out.println("成功!返回" + a);
|
||
|
}
|
||
|
} catch (Exception e) {
|
||
|
e.printStackTrace();
|
||
|
} finally {
|
||
6 years ago
|
module.stop();
|
||
6 years ago
|
}
|
||
|
}
|
||
|
}
|