Browse Source

REPORT-9210 文档demo代码适配10

persist/10.0
yaoh.wu 6 years ago
parent
commit
0251597f7b
  1. 4
      src/com/fr/data/MobileTableWsdlDataDemo.java
  2. 6
      src/com/fr/data/MobileWsdlTableDataDemo.java
  3. 6
      src/com/fr/data/MobileWsdlTableDataDemo1.java
  4. 6
      src/com/fr/data/MobileWsdlTableDataDemoPara.java
  5. 19
      src/com/fr/data/ParamSAPDataTest.java
  6. 4
      src/com/fr/data/ParamTableDataDemo.java
  7. 4
      src/com/fr/data/WebServiceTableData.java
  8. 10
      src/com/fr/data/WebServiceWsdlTableDataDemo2.java
  9. 5
      src/com/fr/data/XMLDemoTableData.java
  10. 10
      src/com/fr/demo/ChangeRowAndCol.java
  11. 5
      src/com/fr/demo/NewDateDemo.java
  12. 6
      src/com/fr/demo/ReadFromDatabase.java
  13. 7
      src/com/fr/demo/SaveReportToDatabase.java
  14. 10
      src/com/fr/demo/SimpleReportletDemo.java
  15. 11
      src/com/fr/demo/URLParameterDemo.java
  16. 5
      src/com/fr/function/ReportCheck.java
  17. 13
      src/com/fr/io/ExcuteDemo.java
  18. 10
      src/com/fr/io/ExportApi.java
  19. 9
      src/com/fr/io/ExportBatch.java
  20. 8
      src/com/fr/io/ExportExcel.java
  21. 9
      src/com/fr/io/ExportReports.java
  22. 9
      src/com/fr/io/JavaPrint.java
  23. 9
      src/com/fr/io/SetParameterWindow.java
  24. 9
      src/com/fr/io/SimpleDemo.java

4
src/com/fr/data/MobileTableWsdlDataDemo.java

@ -20,7 +20,7 @@ public class MobileTableWsdlDataDemo extends AbstractTableData {
private String[][] data;
public MobileTableWsdlDataDemo() {
this.data = this.getData();
this.data = this.getMobileTableWsdlData();
}
@Override
@ -82,7 +82,7 @@ public class MobileTableWsdlDataDemo extends AbstractTableData {
}
public String[][] getData() {
public String[][] getMobileTableWsdlData() {
try {
String url = "http://www.webxml.com.cn/WebServices/MobileCodeWS.asmx?wsdl";
EndpointReference targetEPR = new EndpointReference(url);

6
src/com/fr/data/MobileWsdlTableDataDemo.java

@ -23,7 +23,7 @@ public class MobileWsdlTableDataDemo extends AbstractTableData {
private String[][] data;
public MobileWsdlTableDataDemo() {
this.data = this.getData();
this.data = this.getMobileWsdlTableData();
}
public int getColumnCount() throws TableDataException {
@ -78,7 +78,7 @@ public class MobileWsdlTableDataDemo extends AbstractTableData {
}
public String[][] getData() {
public String[][] getMobileWsdlTableData() {
try {
String url = "http://www.webxml.com.cn/WebServices/MobileCodeWS.asmx?wsdl";
EndpointReference targetEPR = new EndpointReference(url);
@ -102,8 +102,6 @@ public class MobileWsdlTableDataDemo extends AbstractTableData {
OMElement result1 = sender.sendReceive(method);
String[][] result = getResults(result1);
return result;
} catch (org.apache.axis2.AxisFault e) {
e.printStackTrace();
} catch (java.rmi.RemoteException e) {
e.printStackTrace();
}

6
src/com/fr/data/MobileWsdlTableDataDemo1.java

@ -17,7 +17,7 @@ public class MobileWsdlTableDataDemo1 extends AbstractTableData {
private String[][] data;
public MobileWsdlTableDataDemo1() {
this.data = this.getData();
this.data = this.getMobileWsdlTableData();
}
public int getColumnCount() throws TableDataException {
@ -72,7 +72,7 @@ public class MobileWsdlTableDataDemo1 extends AbstractTableData {
}
public String[][] getData() {
public String[][] getMobileWsdlTableData() {
try {
String url = "http://www.webxml.com.cn/WebServices/MobileCodeWS.asmx?wsdl";
EndpointReference targetEPR = new EndpointReference(url);
@ -98,8 +98,6 @@ public class MobileWsdlTableDataDemo1 extends AbstractTableData {
return result;
} catch (org.apache.axis2.AxisFault e) {
e.printStackTrace();
} catch (java.rmi.RemoteException e) {
e.printStackTrace();
}
return new String[][]{{}};
}

6
src/com/fr/data/MobileWsdlTableDataDemoPara.java

@ -18,7 +18,7 @@ public class MobileWsdlTableDataDemoPara extends AbstractTableData {
private String[][] data;
public MobileWsdlTableDataDemoPara() {
this.data = this.getData();
this.data = this.getMobileWsdlTableData();
}
public int getColumnCount() throws TableDataException {
@ -69,7 +69,7 @@ public class MobileWsdlTableDataDemoPara extends AbstractTableData {
}
public String[][] getData() {
public String[][] getMobileWsdlTableData() {
try {
FRLogger.getLogger().error("进入了");
String url = "http://www.webxml.com.cn/WebServices/MobileCodeWS.asmx?wsdl";
@ -99,8 +99,6 @@ public class MobileWsdlTableDataDemoPara extends AbstractTableData {
OMElement result1 = sender.sendReceive(method);
String[][] result = getResults(result1);
return result;
} catch (org.apache.axis2.AxisFault e) {
e.printStackTrace();
} catch (java.rmi.RemoteException e) {
e.printStackTrace();
}

19
src/com/fr/data/ParamSAPDataTest.java

@ -1,13 +1,16 @@
package com.fr.data;
import com.fr.base.FRContext;
import com.fr.base.Parameter;
import com.fr.config.holder.impl.xml.XmlColConf;
import com.fr.function.ConnectSAPServer;
import com.fr.stable.ParameterProvider;
import com.sap.conn.jco.JCoDestination;
import com.sap.conn.jco.JCoException;
import com.sap.conn.jco.JCoFunction;
import com.sap.conn.jco.JCoTable;
import java.util.ArrayList;
public class ParamSAPDataTest extends AbstractTableData {
private String[] columnNames = null;
@ -18,8 +21,12 @@ public class ParamSAPDataTest extends AbstractTableData {
private static JCoDestination jCoDestination;
public ParamSAPDataTest() {
this.parameters = new Parameter[]{new Parameter("LIFNR"),
new Parameter("NAME1")};
ArrayList<String> arrayList = new ArrayList<>();
arrayList.add("LIFNR");
arrayList.add("NAME1");
this.parameters = new XmlColConf<>(arrayList, ParameterProvider.class);
this.columnNames = new String[this.columnNum];
this.columnNames[0] = "供应商编码";
@ -69,8 +76,10 @@ public class ParamSAPDataTest extends AbstractTableData {
if (function == null)
throw new RuntimeException(
"Function not found in SAP.");
function.getImportParameterList().setValue("LIFNR", "%" + this.parameters[0].getValue().toString().toUpperCase().trim() + "%");
function.getImportParameterList().setValue("NAME1", "%" + this.parameters[1].getValue().toString().toUpperCase().trim() + "%");
function.getImportParameterList().setValue("LIFNR", "%" +
((ParameterProvider) (parameters.get().toArray()[0])).getValue().toString().toUpperCase().trim() + "%");
function.getImportParameterList().setValue("NAME1", "%" + ((ParameterProvider) (parameters.get().toArray()[1]))
.getValue().toString().toUpperCase().trim() + "%");
function.execute(jCoDestination);
JCoTable returnTable = function.getTableParameterList().getTable(
"ZLFA1S3");

4
src/com/fr/data/ParamTableDataDemo.java

@ -2,6 +2,7 @@ package com.fr.data;
import com.fr.base.FRContext;
import com.fr.file.DatasourceManager;
import com.fr.stable.ParameterProvider;
import java.sql.Connection;
import java.sql.DriverManager;
@ -82,8 +83,7 @@ public class ParamTableDataDemo extends AbstractTableData {
return;
}
// 保存得到的数据库表名
String tableName = parameters[0].getValue().toString();
String tableName = ((ParameterProvider) (parameters.get().toArray())[0]).getValue().toString();
// 构造SQL语句,并打印出来
String sql = "select * from " + tableName;

4
src/com/fr/data/WebServiceTableData.java

@ -10,7 +10,7 @@ public class WebServiceTableData extends AbstractTableData {
private String[][] data;
public WebServiceTableData() {
this.data = this.getData();
this.data = this.getWebServiceTableData();
}
//获取列数
@ -41,7 +41,7 @@ public class WebServiceTableData extends AbstractTableData {
return data[rowIndex + 1][columnIndex];
}
public String[][] getData() {
public String[][] getWebServiceTableData() {
try {
String endpoint = "http://localhost:8080/axis/TestWS2TDClient.jws";
Service service = new Service();

10
src/com/fr/data/WebServiceWsdlTableDataDemo2.java

@ -11,7 +11,7 @@ public class WebServiceWsdlTableDataDemo2 extends AbstractTableData {
private String[][] data;
public WebServiceWsdlTableDataDemo2() {
this.data = this.getData();
this.data = this.getWebServiceWsdlTableData();
}
public int getColumnCount() throws TableDataException {
@ -33,7 +33,7 @@ public class WebServiceWsdlTableDataDemo2 extends AbstractTableData {
return data[rowIndex + 1][columnIndex];
}
public String[][] getData() {
public String[][] getWebServiceWsdlTableData() {
try {
String url = "http://www.webxml.com.cn/WebServices/MobileCodeWS.asmx?wsdl";
MobileCodeWSStub stub = new MobileCodeWSStub(url);
@ -55,8 +55,6 @@ public class WebServiceWsdlTableDataDemo2 extends AbstractTableData {
}
}
return result;
} catch (org.apache.axis2.AxisFault e) {
e.printStackTrace();
} catch (java.rmi.RemoteException e) {
e.printStackTrace();
}
@ -64,8 +62,8 @@ public class WebServiceWsdlTableDataDemo2 extends AbstractTableData {
}
public static void main(String[] args) {
for (int i = 0; i < new WebServiceWsdlTableDataDemo2().getData().length; i++) {
System.out.println(new WebServiceWsdlTableDataDemo2().getData()[i]);
for (int i = 0; i < new WebServiceWsdlTableDataDemo2().getWebServiceWsdlTableData().length; i++) {
System.out.println(new WebServiceWsdlTableDataDemo2().getWebServiceWsdlTableData()[i]);
}
}
}

5
src/com/fr/data/XMLDemoTableData.java

@ -1,6 +1,7 @@
package com.fr.data;
import com.fr.base.Parameter;
import com.fr.config.holder.impl.xml.XmlColConf;
import com.fr.general.data.DataModel;
import com.fr.script.Calculator;
import com.fr.stable.ParameterProvider;
@ -29,8 +30,8 @@ public class XMLDemoTableData extends AbstractParameterTableData {
// 构造函数
public XMLDemoTableData() {
// 定义需要的参数,这里定义一个参数,参数名为filename,给其一个默认值"Northwind.xml"
this.parameters = new Parameter[1];
this.parameters[0] = new Parameter("filename", "Northwind");
this.parameters = new XmlColConf<>(new ArrayList(), ParameterProvider.class);
parameters.add(new Parameter("filename", "Northwind"));
}
/**

10
src/com/fr/demo/ChangeRowAndCol.java

@ -1,8 +1,6 @@
//遍历单元格
package com.fr.demo;
import com.fr.base.Env;
import com.fr.base.FRContext;
import com.fr.io.TemplateWorkBookIO;
import com.fr.main.TemplateWorkBook;
import com.fr.report.cell.TemplateCellElement;
@ -10,6 +8,7 @@ import com.fr.report.elementcase.TemplateElementCase;
import com.fr.report.worksheet.WorkSheet;
import com.fr.web.core.Reportlet;
import com.fr.web.request.ReportletRequest;
import com.fr.workspace.simple.SimpleWork;
import java.util.Map;
@ -18,12 +17,13 @@ public class ChangeRowAndCol extends Reportlet {
public TemplateWorkBook createReport(ReportletRequest reportletrequest) {
// 定义最终需要返回的WorkBook对象
TemplateWorkBook workbook = null;
Env oldEnv = FRContext.getCurrentEnv();
String envPath = "D:\\FineReport_8.0\\WebReport\\WEB-INF";
SimpleWork.checkIn(envPath);
WorkSheet newworksheet = new WorkSheet();
String change = "0";
try {
// 读取模板保存为WorkBook对象
workbook = TemplateWorkBookIO.readTemplateWorkBook(oldEnv,
workbook = TemplateWorkBookIO.readTemplateWorkBook(
"\\doc\\Primary\\GroupReport\\Group.cpt");
// 读取请求中的参数判断是否需要切换行列显示,0表示不切换,1表示切换
if (reportletrequest.getParameter("change") != null) {
@ -59,6 +59,8 @@ public class ChangeRowAndCol extends Reportlet {
}
} catch (Exception e) {
e.printStackTrace();
} finally {
SimpleWork.checkOut();
}
return workbook;
}

5
src/com/fr/demo/NewDateDemo.java

@ -1,8 +1,6 @@
//<EFBFBD><EFBFBD>̬<EFBFBD>޸<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
package com.fr.demo;
import com.fr.base.Env;
import com.fr.base.FRContext;
import com.fr.data.ArrayTableDataDemo;
import com.fr.general.ModuleContext;
import com.fr.io.TemplateWorkBookIO;
@ -16,11 +14,10 @@ import java.util.Map;
public class NewDateDemo extends Reportlet {
public TemplateWorkBook createReport(ReportletRequest reportletrequest) {
TemplateWorkBook workbook = null;
Env oldEnv = FRContext.getCurrentEnv();
ModuleContext.startModule(EngineModule.class.getName());
try {
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD>workbook<EFBFBD><EFBFBD><EFBFBD>󣬽<EFBFBD>ģ<EFBFBD><EFBFBD><EFBFBD>Ϊworkbook<EFBFBD><EFBFBD><EFBFBD>󲢷<EFBFBD><EFBFBD><EFBFBD>
workbook = TemplateWorkBookIO.readTemplateWorkBook(oldEnv, "1.cpt");
workbook = TemplateWorkBookIO.readTemplateWorkBook("1.cpt");
ArrayTableDataDemo a = new ArrayTableDataDemo(); // <EFBFBD><EFBFBD><EFBFBD>ö<EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
workbook.putTableData("ds2", a); // <EFBFBD><EFBFBD>ģ<EFBFBD><EFBFBD>µ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݼ<EFBFBD>
} catch (Exception e) {

6
src/com/fr/demo/ReadFromDatabase.java

@ -1,11 +1,11 @@
package com.fr.demo;
import com.fr.base.FRContext;
import com.fr.dav.LocalEnv;
import com.fr.main.TemplateWorkBook;
import com.fr.main.impl.WorkBook;
import com.fr.web.core.Reportlet;
import com.fr.web.request.ReportletRequest;
import com.fr.workspace.simple.SimpleWork;
import java.io.InputStream;
import java.sql.Blob;
@ -20,7 +20,7 @@ public class ReadFromDatabase extends Reportlet {
public TemplateWorkBook createReport(ReportletRequest reportletRequest) {
// 定义报表运行环境,才能执行报表
String envpath = "D:\\FineReport_8.0\\WebReport\\WEB-INF";
FRContext.setCurrentEnv(new LocalEnv(envpath));
SimpleWork.checkIn(envpath);
WorkBook workbook = new WorkBook();
String name = reportletRequest.getParameter("cptname").toString();
@ -45,6 +45,8 @@ public class ReadFromDatabase extends Reportlet {
}
} catch (Exception e) {
e.printStackTrace();
} finally {
SimpleWork.checkOut();
}
return workbook;
}

7
src/com/fr/demo/SaveReportToDatabase.java

@ -1,7 +1,6 @@
package com.fr.demo;
import com.fr.base.FRContext;
import com.fr.dav.LocalEnv;
import com.fr.workspace.simple.SimpleWork;
import java.io.File;
import java.io.FileInputStream;
@ -19,7 +18,7 @@ public class SaveReportToDatabase {
try {
// 定义报表运行环境,才能执行报表
String envpath = "D:\\FineReport_8.0\\WebReport\\WEB-INF";
FRContext.setCurrentEnv(new LocalEnv(envpath));
SimpleWork.checkIn(envpath);
// 连接数据库
String driver = "com.mysql.jdbc.Driver";
String url = "jdbc:mysql://112.124.109.239:3306/yourdatabase";
@ -44,6 +43,8 @@ public class SaveReportToDatabase {
conn.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
SimpleWork.checkOut();
}
}
}

10
src/com/fr/demo/SimpleReportletDemo.java

@ -1,27 +1,29 @@
//程序网络报表
package com.fr.demo;
import com.fr.base.Env;
import com.fr.base.FRContext;
import com.fr.io.TemplateWorkBookIO;
import com.fr.main.TemplateWorkBook;
import com.fr.web.core.Reportlet;
import com.fr.web.request.ReportletRequest;
import com.fr.workspace.simple.SimpleWork;
import java.util.Map;
public class SimpleReportletDemo extends Reportlet {
public TemplateWorkBook createReport(ReportletRequest reportletrequest) {
String envPath = "D:\\FineReport_8.0\\WebReport\\WEB-INF";
SimpleWork.checkIn(envPath);
// 新建一个WorkBook对象,用于保存最终返回的报表
Env oldEnv = FRContext.getCurrentEnv();
TemplateWorkBook WorkBook = null;
try {
// 读取模板,将模板保存为workbook对象并返回
WorkBook = TemplateWorkBookIO.readTemplateWorkBook(oldEnv,
WorkBook = TemplateWorkBookIO.readTemplateWorkBook(
"\\doc\\Primary\\Parameter\\Parameter.cpt");
} catch (Exception e) {
e.getStackTrace();
} finally {
SimpleWork.checkOut();
}
return WorkBook;
}

11
src/com/fr/demo/URLParameterDemo.java

@ -1,15 +1,14 @@
// 程序网络报表中获取request中的值
package com.fr.demo;
import com.fr.base.FRContext;
import com.fr.base.Parameter;
import com.fr.dav.LocalEnv;
import com.fr.general.ModuleContext;
import com.fr.io.TemplateWorkBookIO;
import com.fr.main.TemplateWorkBook;
import com.fr.report.module.EngineModule;
import com.fr.web.core.Reportlet;
import com.fr.web.request.ReportletRequest;
import com.fr.workspace.simple.SimpleWork;
import java.util.Map;
@ -18,14 +17,13 @@ public class URLParameterDemo extends Reportlet {
public TemplateWorkBook createReport(ReportletRequest reportletRequest) {
String envPath = "D:\\FineReport_8.0\\WebReport\\WEB-INF";
FRContext.setCurrentEnv(new LocalEnv(envPath));
SimpleWork.checkIn(envPath);
ModuleContext.startModule(EngineModule.class.getName());
// 获取外部传来的参数
TemplateWorkBook wbTpl = null;
String countryValue = reportletRequest.getParameter("地区").toString();
try {
wbTpl = TemplateWorkBookIO.readTemplateWorkBook(
FRContext.getCurrentEnv(), "\\doc\\Primary\\Parameter\\Parameter.cpt");
wbTpl = TemplateWorkBookIO.readTemplateWorkBook("\\doc\\Primary\\Parameter\\Parameter.cpt");
// 提取报表参数组,由于原模板只有country一个参数,因此直接取index为0的参数,并将外部传入的值赋给该参数
Parameter[] ps = wbTpl.getParameters();
ps[0].setValue(countryValue);
@ -34,7 +32,8 @@ public class URLParameterDemo extends Reportlet {
wbTpl.getReportParameterAttr().setParameterUI(null);
} catch (Exception e) {
e.printStackTrace();
return null;
} finally {
SimpleWork.checkOut();
}
return wbTpl;
}

5
src/com/fr/function/ReportCheck.java

@ -1,8 +1,6 @@
// 自定义函数实现表间校验
package com.fr.function;
import com.fr.base.Env;
import com.fr.base.FRContext;
import com.fr.base.ResultFormula;
import com.fr.io.TemplateWorkBookIO;
import com.fr.json.JSONArray;
@ -28,12 +26,11 @@ public class ReportCheck extends AbstractFunction {
// 定义返回的值
Object returnValue = null;
// 定义报表运行环境,才能运行读取的报表
Env oldEnv = FRContext.getCurrentEnv();
try {
ResultWorkBook rworkbook = null;
// 读取模板
WorkBook workbook = (WorkBook) TemplateWorkBookIO
.readTemplateWorkBook(oldEnv, cptname);
.readTemplateWorkBook(cptname);
// 获取需要传递给报表的参数名与参数值,格式如[{"name":para1name,"value":para1value},{"name":para2name,"value":para2value},......]
JSONArray parasArray = new JSONArray(args[1].toString());
// 需要判断是否是5秒内执行过的

13
src/com/fr/io/ExcuteDemo.java

@ -1,13 +1,14 @@
package com.fr.io;
import com.fr.base.FRContext;
import com.fr.dav.LocalEnv;
import com.fr.base.operator.common.CommonOperator;
import com.fr.env.operator.CommonOperatorImpl;
import com.fr.general.ModuleContext;
import com.fr.io.exporter.ExcelExporter;
import com.fr.main.TemplateWorkBook;
import com.fr.main.workbook.ResultWorkBook;
import com.fr.report.module.EngineModule;
import com.fr.stable.WriteActor;
import com.fr.workspace.simple.SimpleWork;
import java.io.File;
import java.io.FileOutputStream;
@ -18,10 +19,12 @@ public class ExcuteDemo {
try {
// 首先需要定义执行所在的环境,这样才能正确读取数据库信息
String envPath = "D:\\FineReport_8.0\\WebReport\\WEB-INF";
FRContext.setCurrentEnv(new LocalEnv(envPath));
SimpleWork.checkIn(envPath);
ModuleContext.startModule(EngineModule.class.getName());
// 读取模板
TemplateWorkBook workbook = TemplateWorkBookIO.readTemplateWorkBook(FRContext.getCurrentEnv(), "\\doc\\Primary\\Parameter\\Parameter.cpt");
TemplateWorkBook workbook = TemplateWorkBookIO.readTemplateWorkBook("\\doc\\Primary\\Parameter\\Parameter.cpt");
/*
* 生成参数map注入参数与对应的值用于执行报表 该模板中只有一个参数地区给其赋值华北
* 若参数在发送请求时传过来可以通过req.getParameter(name)获得
@ -38,6 +41,8 @@ public class ExcuteDemo {
excelExporter.export(outputStream, result);
} catch (Exception e) {
e.printStackTrace();
} finally {
SimpleWork.checkOut();
}
}
}

10
src/com/fr/io/ExportApi.java

@ -1,8 +1,6 @@
package com.fr.io;
import com.fr.base.FRContext;
import com.fr.base.Parameter;
import com.fr.dav.LocalEnv;
import com.fr.general.ModuleContext;
import com.fr.io.exporter.CSVExporter;
import com.fr.io.exporter.EmbeddedTableDataExporter;
@ -17,6 +15,7 @@ import com.fr.main.impl.WorkBook;
import com.fr.main.workbook.ResultWorkBook;
import com.fr.report.module.EngineModule;
import com.fr.stable.WriteActor;
import com.fr.workspace.simple.SimpleWork;
import java.io.File;
import java.io.FileOutputStream;
@ -26,14 +25,13 @@ public class ExportApi {
public static void main(String[] args) {
// 定义报表运行环境,才能执行报表
String envpath = "D:\\FineReport_8.0\\WebReport\\WEB-INF";
FRContext.setCurrentEnv(new LocalEnv(envpath));
SimpleWork.checkIn(envpath);
ModuleContext.startModule(EngineModule.class.getName());
ResultWorkBook rworkbook = null;
try {
// 未执行模板工作薄
WorkBook workbook = (WorkBook) TemplateWorkBookIO
.readTemplateWorkBook(FRContext.getCurrentEnv(),
"\\doc\\Primary\\Parameter\\Parameter.cpt");
.readTemplateWorkBook("\\doc\\Primary\\Parameter\\Parameter.cpt");
// 获取报表参数并设置值,导出内置数据集时数据集会根据参数值查询出结果从而转为内置数据集
Parameter[] parameters = workbook.getParameters();
parameters[0].setValue("华东");
@ -88,6 +86,8 @@ public class ExportApi {
ModuleContext.stopModules();
} catch (Exception e) {
e.printStackTrace();
} finally {
SimpleWork.checkOut();
}
}
}

9
src/com/fr/io/ExportBatch.java

@ -1,7 +1,5 @@
package com.fr.io;
import com.fr.base.FRContext;
import com.fr.dav.LocalEnv;
import com.fr.general.ModuleContext;
import com.fr.io.exporter.ExcelExporter;
import com.fr.main.TemplateWorkBook;
@ -9,6 +7,7 @@ import com.fr.main.workbook.ResultWorkBook;
import com.fr.report.module.EngineModule;
import com.fr.stable.StableUtils;
import com.fr.stable.WriteActor;
import com.fr.workspace.simple.SimpleWork;
import java.io.BufferedReader;
import java.io.File;
@ -24,10 +23,10 @@ public class ExportBatch {
try {
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>л<EFBFBD><EFBFBD><EFBFBD>,<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD>б<EFBFBD><EFBFBD><EFBFBD>
String envpath = "D:\\FineReport_7.1\\WebReport\\WEB-INF";
FRContext.setCurrentEnv(new LocalEnv(envpath));
SimpleWork.checkIn(envpath);
ModuleContext.startModule(EngineModule.class.getName());
// <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD>ģ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
TemplateWorkBook workbook = TemplateWorkBookIO.readTemplateWorkBook(FRContext.getCurrentEnv(),
TemplateWorkBook workbook = TemplateWorkBookIO.readTemplateWorkBook(
"doc\\Primary\\DetailReport\\Details.cpt");
// <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>ڱ<EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD>txt<EFBFBD>ļ<EFBFBD>
File parafile = new File(envpath + "\\para.txt");
@ -65,6 +64,8 @@ public class ExportBatch {
ModuleContext.stopModules();
} catch (Exception e) {
e.printStackTrace();
} finally {
SimpleWork.checkOut();
}
}
}

8
src/com/fr/io/ExportExcel.java

@ -1,8 +1,6 @@
package com.fr.io;
import com.fr.base.FRContext;
import com.fr.base.Parameter;
import com.fr.dav.LocalEnv;
import com.fr.general.ModuleContext;
import com.fr.io.exporter.ExcelExporter;
import com.fr.io.exporter.LargeDataPageExcelExporter;
@ -16,6 +14,7 @@ import com.fr.main.workbook.ResultWorkBook;
import com.fr.report.core.ReportUtils;
import com.fr.report.module.EngineModule;
import com.fr.stable.WriteActor;
import com.fr.workspace.simple.SimpleWork;
import java.io.File;
import java.io.FileOutputStream;
@ -25,14 +24,13 @@ public class ExportExcel {
public static void main(String[] args) {
// 定义报表运行环境,才能执行报表
String envpath = "D:\\FineReport_8.0\\WebReport\\WEB-INF";
FRContext.setCurrentEnv(new LocalEnv(envpath));
SimpleWork.checkIn(envpath);
ModuleContext.startModule(EngineModule.class.getName());
ResultWorkBook rworkbook = null;
try {
// 未执行模板工作薄
WorkBook workbook = (WorkBook) TemplateWorkBookIO
.readTemplateWorkBook(FRContext.getCurrentEnv(),
"\\doc\\Primary\\Parameter\\Parameter.cpt");
.readTemplateWorkBook("\\doc\\Primary\\Parameter\\Parameter.cpt");
// 获取报表参数并设置值,导出内置数据集时数据集会根据参数值查询出结果从而转为内置数据集
Parameter[] parameters = workbook.getParameters();
parameters[0].setValue("华东");

9
src/com/fr/io/ExportReports.java

@ -1,8 +1,6 @@
package com.fr.io;
import com.fr.base.FRContext;
import com.fr.base.Parameter;
import com.fr.dav.LocalEnv;
import com.fr.general.ModuleContext;
import com.fr.io.exporter.PageExcelExporter;
import com.fr.main.TemplateWorkBook;
@ -11,6 +9,7 @@ import com.fr.report.core.ReportUtils;
import com.fr.report.module.EngineModule;
import com.fr.report.report.PageReport;
import com.fr.stable.PageActor;
import com.fr.workspace.simple.SimpleWork;
import java.io.File;
import java.io.FileOutputStream;
@ -20,12 +19,12 @@ public class ExportReports {
public static void main(String[] args) {
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>л<EFBFBD><EFBFBD><EFBFBD>,<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD>б<EFBFBD><EFBFBD><EFBFBD>
String envpath = "D:\\FineReport\\develop\\code\\build\\package\\WebReport\\WEB-INF";
FRContext.setCurrentEnv(new LocalEnv(envpath));
SimpleWork.checkIn(envpath);
ModuleContext.startModule(EngineModule.class.getName());
// <EFBFBD><EFBFBD><EFBFBD>г<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һЩ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>
try {
// δִ<EFBFBD><EFBFBD>ģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
TemplateWorkBook workbook = TemplateWorkBookIO.readTemplateWorkBook(FRContext.getCurrentEnv(),
TemplateWorkBook workbook = TemplateWorkBookIO.readTemplateWorkBook(
"Gettingstarted.cpt");
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵΪChina<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>rworkbook
Parameter[] parameters = workbook.getParameters();
@ -52,6 +51,8 @@ public class ExportReports {
} catch (Exception e) {
e.printStackTrace();
} finally {
SimpleWork.checkOut();
}
}
}

9
src/com/fr/io/JavaPrint.java

@ -1,10 +1,9 @@
package com.fr.io;
import com.fr.base.FRContext;
import com.fr.base.Parameter;
import com.fr.dav.LocalEnv;
import com.fr.main.TemplateWorkBook;
import com.fr.print.PrintUtils;
import com.fr.workspace.simple.SimpleWork;
import java.util.HashMap;
@ -13,9 +12,9 @@ public class JavaPrint {
public static void main(String[] args) {
// 定义报表运行环境,才能执行报表
String envPath = "D:\\FineReport\\develop\\code\\build\\package\\WebReport\\WEB-INF";
FRContext.setCurrentEnv(new LocalEnv(envPath));
SimpleWork.checkIn(envPath);
try {
TemplateWorkBook workbook = TemplateWorkBookIO.readTemplateWorkBook(FRContext.getCurrentEnv(), "GettingStarted.cpt");
TemplateWorkBook workbook = TemplateWorkBookIO.readTemplateWorkBook("GettingStarted.cpt");
// 参数传值
Parameter[] parameters = workbook.getParameters();
HashMap<String, String> paraMap = new HashMap<String, String>();
@ -30,6 +29,8 @@ public class JavaPrint {
}
} catch (Exception e) {
e.printStackTrace();
} finally {
SimpleWork.checkOut();
}
}
}

9
src/com/fr/io/SetParameterWindow.java

@ -1,15 +1,14 @@
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>API
package com.fr.io;
import com.fr.base.FRContext;
import com.fr.base.background.ColorBackground;
import com.fr.dav.LocalEnv;
import com.fr.general.Background;
import com.fr.general.ModuleContext;
import com.fr.io.exporter.EmbeddedTableDataExporter;
import com.fr.main.impl.WorkBook;
import com.fr.main.parameter.ReportParameterAttr;
import com.fr.report.module.EngineModule;
import com.fr.workspace.simple.SimpleWork;
import java.awt.Color;
import java.io.File;
@ -20,11 +19,11 @@ public class SetParameterWindow {
try {
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>л<EFBFBD><EFBFBD><EFBFBD>,<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD>б<EFBFBD><EFBFBD><EFBFBD>
String envPath = "D:\\FineReport\\develop\\code\\build\\package\\WebReport\\WEB-INF";
FRContext.setCurrentEnv(new LocalEnv(envPath));
SimpleWork.checkIn(envPath);
ModuleContext.startModule(EngineModule.class.getName());
// <EFBFBD><EFBFBD>ȡģ<EFBFBD><EFBFBD><EFBFBD>ΪWorkBook<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
WorkBook workbook = (WorkBook) TemplateWorkBookIO
.readTemplateWorkBook(FRContext.getCurrentEnv(),
.readTemplateWorkBook(
"\\doc\\Primary\\Parameter\\Parameter.cpt");
// <EFBFBD><EFBFBD>ȡWorkBook<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ReportParameterAttr
ReportParameterAttr paraAttr = workbook.getReportParameterAttr();
@ -52,6 +51,8 @@ public class SetParameterWindow {
templateExporter.export(outputStream, workbook);
} catch (Exception e) {
e.printStackTrace();
} finally {
SimpleWork.checkOut();
}
}
}

9
src/com/fr/io/SimpleDemo.java

@ -1,15 +1,14 @@
//<EFBFBD><EFBFBD>ȡ<EFBFBD>޸ı<EFBFBD><EFBFBD><EFBFBD>
package com.fr.io;
import com.fr.base.FRContext;
import com.fr.base.Style;
import com.fr.dav.LocalEnv;
import com.fr.general.FRFont;
import com.fr.general.ModuleContext;
import com.fr.main.impl.WorkBook;
import com.fr.report.cell.CellElement;
import com.fr.report.elementcase.TemplateElementCase;
import com.fr.report.module.EngineModule;
import com.fr.workspace.simple.SimpleWork;
import java.awt.Color;
import java.io.File;
@ -19,12 +18,12 @@ public class SimpleDemo {
public static void main(String[] args) {
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>л<EFBFBD><EFBFBD><EFBFBD>,<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD>б<EFBFBD><EFBFBD><EFBFBD>
String envPath = "D:\\FineReport_7.0\\WebReport\\WEB-INF";
FRContext.setCurrentEnv(new LocalEnv(envPath));
SimpleWork.checkIn(envPath);
ModuleContext.startModule(EngineModule.class.getName());
try {
// <EFBFBD><EFBFBD>ȡģ<EFBFBD><EFBFBD>
WorkBook workbook = (WorkBook) TemplateWorkBookIO
.readTemplateWorkBook(FRContext.getCurrentEnv(),
.readTemplateWorkBook(
"\\doc\\Primary\\Parameter\\Parameter.cpt");
// <EFBFBD><EFBFBD><EFBFBD>WorkBook<EFBFBD>е<EFBFBD>WorkSheet<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸<EFBFBD>A1<EFBFBD><EFBFBD>Ԫ<EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD>ɫΪ<EFBFBD><EFBFBD>ɫ
@ -44,6 +43,8 @@ public class SimpleDemo {
((WorkBook) workbook).export(outputStream);
} catch (Exception e) {
e.printStackTrace();
} finally {
SimpleWork.checkOut();
}
}
}
Loading…
Cancel
Save