今天用了半个小时研究了一下简表。具体简表是什么我就不说了。想知道的话百度一下。
下面是一个简单的例子。想用就拿走吧。
package org.yangzc.report;
import jatools.ReportDocument;
import jatools.designer.export.LocalReportJob;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
public class ReportDemo {
public static final int DHTML2 = 0;
public static final int MHT = 1;
public static final int PDF = 2;
public static final int XLS = 3;
public static final int XLS1 = 4;
public static final int RTF = 5;
public static final int CVS = 6;
public static final int PS = 7;
public static final int PNG = 8;
@SuppressWarnings("unchecked")
public static void main(String[] args) {
//文件路径
String path = "C:/Documents and Settings/Administrator/桌面/财务利润表.xml";
//导出文件路径
String exportPath = "C:/Documents and Settings/Administrator/桌面/财务利润表.pdf";
int type = PDF;
try {
//加载报表文件
ReportDocument doc = ReportDocument.load(new File(path));
Map parameters = new HashMap();
//导出报表
LocalReportJob job = new LocalReportJob(doc, parameters, new File(exportPath));
try {
if (type == DHTML2) {
job.printAsDHTML();
} else if (type == PDF) {
job.printAsPDF();
} else if (type == XLS) {
job.printAsXLS();
} else if (type == XLS1) {
job.printAsXLS1();
} else if (type == RTF) {
job.printAsRTF();
}
} catch (Exception e) {
e.printStackTrace();
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
注:这里需要JOR源代码。并且拷贝jatools.properties到工程下。