parent
9ff1810fbd
commit
1220f1cad4
Binary file not shown.
@ -0,0 +1,48 @@
|
||||
import com.raqsoft.dm.Sequence;
|
||||
import com.raqsoft.report.model.ReportDefine;
|
||||
import com.raqsoft.report.usermodel.Context;
|
||||
import com.raqsoft.report.usermodel.DataSourceConfig;
|
||||
import com.raqsoft.report.usermodel.Engine;
|
||||
import com.raqsoft.report.usermodel.IReport;
|
||||
import com.raqsoft.report.util.ReportUtils;
|
||||
import com.raqsoft.report.util.StyleConfig;
|
||||
import com.raqsoft.report.view.ReportExporter;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.sql.Connection;
|
||||
import java.sql.Driver;
|
||||
import java.sql.DriverManager;
|
||||
|
||||
public class Test {
|
||||
public static void main(String[] args) throws Throwable {
|
||||
// 设置报表授权文件
|
||||
File flic = new File("./reportTrialLicense20211231.xml");
|
||||
FileInputStream lis = new FileInputStream(flic);
|
||||
Sequence.readLicense(Sequence.P_RPT, lis);
|
||||
|
||||
//加载报表
|
||||
String reportFile = "D:\\1.rpx"; //该文件名可以为绝对路径,也可以相对当前程序启动路径
|
||||
ReportDefine rd = (ReportDefine) ReportUtils.read(reportFile);
|
||||
|
||||
//构建报表引擎计算环境
|
||||
Context cxt = new Context();
|
||||
Connection con = null;
|
||||
try {
|
||||
Driver driver = (Driver) Class.forName("org.postgresql.Driver").newInstance();
|
||||
DriverManager.registerDriver(driver);
|
||||
con = DriverManager.getConnection("jdbc:postgresql://10.10.14.206:5432/eduData_db", "root", "DsideaL147258369");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
cxt.setConnection("HUANGHAI", con);
|
||||
cxt.setDefDataSourceName("HUANGHAI");//这样设定默认数据源
|
||||
Engine engine = new Engine(rd, cxt); //构造报表引擎
|
||||
|
||||
IReport iReport = engine.calc(); //运算报表
|
||||
ReportExporter re = new ReportExporter("d:\\1.xls", ReportExporter.EXPORT_EXCEL); //导出为Excel
|
||||
re.export(iReport); //导出
|
||||
|
||||
System.out.println("恭喜,导出成功!");
|
||||
}
|
||||
}
|
Binary file not shown.
Loading…
Reference in new issue