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