From fd21d7c3bb49d300e55d29af38cc06138a6059c9 Mon Sep 17 00:00:00 2001 From: zack Date: Wed, 28 Aug 2019 10:11:17 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-21133=20=E5=AF=BC=E5=87=BAexcel=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E4=B8=8D=E5=AF=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/demo/SaveReportToDatabase.java | 4 +- .../java/com/fr/function/ReportCheck.java | 4 +- .../java/com/fr/io/CreateGenericTemplate.java | 4 +- src/main/java/com/fr/io/ExcelToCpt.java | 4 +- src/main/java/com/fr/io/ExcuteDemo.java | 4 +- src/main/java/com/fr/io/ExportApi.java | 99 ++++++++---------- src/main/java/com/fr/io/ExportBatch.java | 4 +- src/main/java/com/fr/io/ExportExcel.java | 4 +- src/main/java/com/fr/io/ExportReports.java | 4 +- src/main/java/com/fr/io/JavaPrint.java | 4 +- .../java/com/fr/io/SaveReportToDatabase.java | 4 +- .../java/com/fr/io/SetParameterWindow.java | 4 +- src/main/java/com/fr/io/SimpleDemo.java | 4 +- .../WEB-INF/assist/phantomjs/lib/format.js | 0 .../assist/phantomjs/lib/van-convert.js | 0 .../assist/phantomjs/lib/vancharts-all.js | 0 .../phantomjs/phantomjs-linux32/ChangeLog | 0 .../phantomjs/phantomjs-linux32/LICENSE.BSD | 0 .../phantomjs/phantomjs-linux32/README.md | 0 .../phantomjs/phantomjs-linux32/bin/phantomjs | Bin .../phantomjs-linux32/third-party.txt | 0 .../phantomjs/phantomjs-linux64/ChangeLog | 0 .../phantomjs/phantomjs-linux64/LICENSE.BSD | 0 .../phantomjs/phantomjs-linux64/README.md | 0 .../phantomjs/phantomjs-linux64/bin/phantomjs | Bin .../phantomjs-linux64/third-party.txt | 0 .../phantomjs/phantomjs-macos/ChangeLog | 0 .../phantomjs/phantomjs-macos/LICENSE.BSD | 0 .../phantomjs/phantomjs-macos/README.md | 0 .../phantomjs/phantomjs-macos/bin/phantomjs | Bin .../phantomjs/phantomjs-macos/third-party.txt | 0 .../phantomjs/phantomjs-windows/ChangeLog | 0 .../phantomjs/phantomjs-windows/LICENSE.BSD | 0 .../phantomjs/phantomjs-windows/README.md | 0 .../phantomjs-windows/bin/phantomjs.exe | Bin .../phantomjs-windows/third-party.txt | 0 .../phantomjs-winxp/bin/phantomjs.exe | Bin .../java/WEB-INF/reportlets/demo.cpt | 0 .../main/java/WEB-INF/reportlets/sumtest.cpt | 51 +++++++++ .../main/java/com/fr/demo/ExportApiTest.java | 85 +++++++++++++++ .../java/com/fr/demo/ModuleStartTest.java | 5 +- .../java/com/fr/demo/TestLogAppender.java | 0 42 files changed, 222 insertions(+), 66 deletions(-) rename src/test/{ => main}/java/WEB-INF/assist/phantomjs/lib/format.js (100%) rename src/test/{ => main}/java/WEB-INF/assist/phantomjs/lib/van-convert.js (100%) rename src/test/{ => main}/java/WEB-INF/assist/phantomjs/lib/vancharts-all.js (100%) rename src/test/{ => main}/java/WEB-INF/assist/phantomjs/phantomjs-linux32/ChangeLog (100%) rename src/test/{ => main}/java/WEB-INF/assist/phantomjs/phantomjs-linux32/LICENSE.BSD (100%) rename src/test/{ => main}/java/WEB-INF/assist/phantomjs/phantomjs-linux32/README.md (100%) rename src/test/{ => main}/java/WEB-INF/assist/phantomjs/phantomjs-linux32/bin/phantomjs (100%) rename src/test/{ => main}/java/WEB-INF/assist/phantomjs/phantomjs-linux32/third-party.txt (100%) rename src/test/{ => main}/java/WEB-INF/assist/phantomjs/phantomjs-linux64/ChangeLog (100%) rename src/test/{ => main}/java/WEB-INF/assist/phantomjs/phantomjs-linux64/LICENSE.BSD (100%) rename src/test/{ => main}/java/WEB-INF/assist/phantomjs/phantomjs-linux64/README.md (100%) rename src/test/{ => main}/java/WEB-INF/assist/phantomjs/phantomjs-linux64/bin/phantomjs (100%) rename src/test/{ => main}/java/WEB-INF/assist/phantomjs/phantomjs-linux64/third-party.txt (100%) rename src/test/{ => main}/java/WEB-INF/assist/phantomjs/phantomjs-macos/ChangeLog (100%) rename src/test/{ => main}/java/WEB-INF/assist/phantomjs/phantomjs-macos/LICENSE.BSD (100%) rename src/test/{ => main}/java/WEB-INF/assist/phantomjs/phantomjs-macos/README.md (100%) rename src/test/{ => main}/java/WEB-INF/assist/phantomjs/phantomjs-macos/bin/phantomjs (100%) rename src/test/{ => main}/java/WEB-INF/assist/phantomjs/phantomjs-macos/third-party.txt (100%) rename src/test/{ => main}/java/WEB-INF/assist/phantomjs/phantomjs-windows/ChangeLog (100%) rename src/test/{ => main}/java/WEB-INF/assist/phantomjs/phantomjs-windows/LICENSE.BSD (100%) rename src/test/{ => main}/java/WEB-INF/assist/phantomjs/phantomjs-windows/README.md (100%) rename src/test/{ => main}/java/WEB-INF/assist/phantomjs/phantomjs-windows/bin/phantomjs.exe (100%) rename src/test/{ => main}/java/WEB-INF/assist/phantomjs/phantomjs-windows/third-party.txt (100%) rename src/test/{ => main}/java/WEB-INF/assist/phantomjs/phantomjs-winxp/bin/phantomjs.exe (100%) rename src/test/{ => main}/java/WEB-INF/reportlets/demo.cpt (100%) create mode 100644 src/test/main/java/WEB-INF/reportlets/sumtest.cpt create mode 100644 src/test/main/java/com/fr/demo/ExportApiTest.java rename src/test/{ => main}/java/com/fr/demo/ModuleStartTest.java (95%) rename src/test/{ => main}/java/com/fr/demo/TestLogAppender.java (100%) diff --git a/src/main/java/com/fr/demo/SaveReportToDatabase.java b/src/main/java/com/fr/demo/SaveReportToDatabase.java index 971f379..9a5e891 100644 --- a/src/main/java/com/fr/demo/SaveReportToDatabase.java +++ b/src/main/java/com/fr/demo/SaveReportToDatabase.java @@ -12,6 +12,7 @@ import com.fr.module.tool.ActivatorToolBox; import com.fr.report.ReportActivator; import com.fr.report.RestrictionActivator; import com.fr.report.module.ReportBaseActivator; +import com.fr.report.write.WriteActivator; import com.fr.scheduler.SchedulerActivator; import com.fr.store.StateServerActivator; import com.fr.workspace.simple.SimpleWork; @@ -35,11 +36,12 @@ public class SaveReportToDatabase { new ConfigurationActivator(), new StandaloneModeActivator(), new StateServerActivator(), + new ChartBaseActivator(), new SchedulerActivator(), new ReportBaseActivator(), new RestrictionActivator(), new ReportActivator(), - new ChartBaseActivator()); + new WriteActivator()); SimpleWork.supply(CommonOperator.class, new CommonOperatorImpl()); String envpath = "//Applications//FineReport10_325//webapps//webroot//WEB-INF";//工程路径 SimpleWork.checkIn(envpath); diff --git a/src/main/java/com/fr/function/ReportCheck.java b/src/main/java/com/fr/function/ReportCheck.java index 1ade144..095ff3f 100644 --- a/src/main/java/com/fr/function/ReportCheck.java +++ b/src/main/java/com/fr/function/ReportCheck.java @@ -21,6 +21,7 @@ import com.fr.report.RestrictionActivator; import com.fr.report.cell.CellElement; import com.fr.report.module.ReportBaseActivator; import com.fr.report.report.ResultReport; +import com.fr.report.write.WriteActivator; import com.fr.scheduler.SchedulerActivator; import com.fr.script.AbstractFunction; import com.fr.stable.WriteActor; @@ -45,11 +46,12 @@ public class ReportCheck extends AbstractFunction { new ConfigurationActivator(), new StandaloneModeActivator(), new StateServerActivator(), + new ChartBaseActivator(), new SchedulerActivator(), new ReportBaseActivator(), new RestrictionActivator(), new ReportActivator(), - new ChartBaseActivator()); + new WriteActivator()); SimpleWork.supply(CommonOperator.class, new CommonOperatorImpl()); String envpath = "//Applications//FineReport10_325//webapps//webroot//WEB-INF";//工程路径 SimpleWork.checkIn(envpath); diff --git a/src/main/java/com/fr/io/CreateGenericTemplate.java b/src/main/java/com/fr/io/CreateGenericTemplate.java index ba97403..c52f22c 100644 --- a/src/main/java/com/fr/io/CreateGenericTemplate.java +++ b/src/main/java/com/fr/io/CreateGenericTemplate.java @@ -21,6 +21,7 @@ import com.fr.report.cell.TemplateCellElement; import com.fr.report.cell.cellattr.core.group.DSColumn; import com.fr.report.module.ReportBaseActivator; import com.fr.report.worksheet.WorkSheet; +import com.fr.report.write.WriteActivator; import com.fr.scheduler.SchedulerActivator; import com.fr.store.StateServerActivator; import com.fr.workspace.simple.SimpleWork; @@ -37,11 +38,12 @@ public class CreateGenericTemplate { new ConfigurationActivator(), new StandaloneModeActivator(), new StateServerActivator(), + new ChartBaseActivator(), new SchedulerActivator(), new ReportBaseActivator(), new RestrictionActivator(), new ReportActivator(), - new ChartBaseActivator()); + new WriteActivator()); SimpleWork.supply(CommonOperator.class, new CommonOperatorImpl()); String envpath = "//Applications//FineReport10_325//webapps//webroot//WEB-INF";//工程路径 SimpleWork.checkIn(envpath); diff --git a/src/main/java/com/fr/io/ExcelToCpt.java b/src/main/java/com/fr/io/ExcelToCpt.java index 5389be4..d661b81 100644 --- a/src/main/java/com/fr/io/ExcelToCpt.java +++ b/src/main/java/com/fr/io/ExcelToCpt.java @@ -15,6 +15,7 @@ import com.fr.module.tool.ActivatorToolBox; import com.fr.report.ReportActivator; import com.fr.report.RestrictionActivator; import com.fr.report.module.ReportBaseActivator; +import com.fr.report.write.WriteActivator; import com.fr.scheduler.SchedulerActivator; import com.fr.store.StateServerActivator; import com.fr.workspace.simple.SimpleWork; @@ -32,11 +33,12 @@ public class ExcelToCpt { new ConfigurationActivator(), new StandaloneModeActivator(), new StateServerActivator(), + new ChartBaseActivator(), new SchedulerActivator(), new ReportBaseActivator(), new RestrictionActivator(), new ReportActivator(), - new ChartBaseActivator()); + new WriteActivator()); SimpleWork.supply(CommonOperator.class, new CommonOperatorImpl()); String envpath = "//Applications//FineReport10_325//webapps//webroot//WEB-INF";//工程路径 SimpleWork.checkIn(envpath); diff --git a/src/main/java/com/fr/io/ExcuteDemo.java b/src/main/java/com/fr/io/ExcuteDemo.java index 742e640..944f977 100644 --- a/src/main/java/com/fr/io/ExcuteDemo.java +++ b/src/main/java/com/fr/io/ExcuteDemo.java @@ -15,6 +15,7 @@ import com.fr.module.tool.ActivatorToolBox; import com.fr.report.ReportActivator; import com.fr.report.RestrictionActivator; import com.fr.report.module.ReportBaseActivator; +import com.fr.report.write.WriteActivator; import com.fr.scheduler.SchedulerActivator; import com.fr.stable.WriteActor; import com.fr.store.StateServerActivator; @@ -33,11 +34,12 @@ public class ExcuteDemo { new ConfigurationActivator(), new StandaloneModeActivator(), new StateServerActivator(), + new ChartBaseActivator(), new SchedulerActivator(), new ReportBaseActivator(), new RestrictionActivator(), new ReportActivator(), - new ChartBaseActivator()); + new WriteActivator()); SimpleWork.supply(CommonOperator.class, new CommonOperatorImpl()); String envpath = "//Applications//FineReport10_325//webapps//webroot//WEB-INF";//工程路径 SimpleWork.checkIn(envpath); diff --git a/src/main/java/com/fr/io/ExportApi.java b/src/main/java/com/fr/io/ExportApi.java index 4157630..6588771 100644 --- a/src/main/java/com/fr/io/ExportApi.java +++ b/src/main/java/com/fr/io/ExportApi.java @@ -1,6 +1,5 @@ package com.fr.io; -import com.fr.base.Parameter; import com.fr.base.operator.common.CommonOperator; import com.fr.chart.activator.ChartBaseActivator; import com.fr.cluster.engine.activator.standalone.StandaloneModeActivator; @@ -8,14 +7,6 @@ import com.fr.config.activator.BaseDBActivator; import com.fr.config.activator.ConfigurationActivator; import com.fr.env.operator.CommonOperatorImpl; import com.fr.general.I18nResource; -import com.fr.io.exporter.CSVExporter; -import com.fr.io.exporter.EmbeddedTableDataExporter; -import com.fr.io.exporter.ExcelExporter; -import com.fr.io.exporter.ImageExporter; -import com.fr.io.exporter.PDFExporter; -import com.fr.io.exporter.SVGExporter; -import com.fr.io.exporter.TextExporter; -import com.fr.io.exporter.WordExporter; import com.fr.io.exporter.excel.stream.StreamExcel2007Exporter; import com.fr.main.impl.WorkBook; import com.fr.main.workbook.ResultWorkBook; @@ -24,6 +15,7 @@ import com.fr.module.tool.ActivatorToolBox; import com.fr.report.ReportActivator; import com.fr.report.RestrictionActivator; import com.fr.report.module.ReportBaseActivator; +import com.fr.report.write.WriteActivator; import com.fr.scheduler.SchedulerActivator; import com.fr.stable.WriteActor; import com.fr.store.StateServerActivator; @@ -44,9 +36,10 @@ public class ExportApi { new ReportBaseActivator(), new RestrictionActivator(), new ReportActivator(), + new WriteActivator(), new ChartBaseActivator()); SimpleWork.supply(CommonOperator.class, new CommonOperatorImpl()); - String envpath = "//Applications//FineReport10_325//webapps//webroot//WEB-INF";//工程路径 + String envpath = "E:\\默认工程\\webroot\\WEB-INF\\";//工程路径 SimpleWork.checkIn(envpath); I18nResource.getInstance(); module.start(); @@ -56,57 +49,57 @@ public class ExportApi { try { // 未执行模板工作薄 WorkBook workbook = (WorkBook) TemplateWorkBookIO - .readTemplateWorkBook("//doc//Primary//Parameter//Parameter.cpt"); + .readTemplateWorkBook("test.cpt"); // 获取报表参数并设置值,导出内置数据集时数据集会根据参数值查询出结果从而转为内置数据集 - Parameter[] parameters = workbook.getParameters(); - parameters[0].setValue("华东"); +// Parameter[] parameters = workbook.getParameters(); +// parameters[0].setValue("华东"); // 定义parametermap用于执行报表,将执行后的结果工作薄保存为rworkBook java.util.Map parameterMap = new java.util.HashMap(); - for (int i = 0; i < parameters.length; i++) { - parameterMap.put(parameters[i].getName(), parameters[i] - .getValue()); - } +// for (int i = 0; i < parameters.length; i++) { +// parameterMap.put(parameters[i].getName(), parameters[i] +// .getValue()); +// } // 定义输出流 FileOutputStream outputStream; - // 将未执行模板工作薄导出为内置数据集模板 - outputStream = new FileOutputStream(new File("/Users//susie//Downloads//EmbExport.cpt")); - EmbeddedTableDataExporter templateExporter = new EmbeddedTableDataExporter(); - templateExporter.export(outputStream, workbook); - // 将模板工作薄导出模板文件,在导出前您可以编辑导入的模板工作薄,可参考报表调用章节 - outputStream = new FileOutputStream(new File("/Users//susie//Downloads//TmpExport.cpt")); - ((WorkBook) workbook).export(outputStream); - // 将结果工作薄导出为2003Excel文件 - outputStream = new FileOutputStream(new File("/Users//susie//Downloads//ExcelExport.xls")); - ExcelExporter ExcelExport = new ExcelExporter(); - ExcelExport.export(outputStream, workbook.execute(parameterMap, new WriteActor())); +// // 将未执行模板工作薄导出为内置数据集模板 +// outputStream = new FileOutputStream(new File("/Users//susie//Downloads//EmbExport.cpt")); +// EmbeddedTableDataExporter templateExporter = new EmbeddedTableDataExporter(); +// templateExporter.export(outputStream, workbook); +// // 将模板工作薄导出模板文件,在导出前您可以编辑导入的模板工作薄,可参考报表调用章节 +// outputStream = new FileOutputStream(new File("/Users//susie//Downloads//TmpExport.cpt")); +// ((WorkBook) workbook).export(outputStream); +// // 将结果工作薄导出为2003Excel文件 +// outputStream = new FileOutputStream(new File("/Users//susie//Downloads//ExcelExport.xls")); +// ExcelExporter ExcelExport = new ExcelExporter(); +// ExcelExport.export(outputStream, workbook.execute(parameterMap, new WriteActor())); // 将结果工作薄导出为Excel文件 - outputStream = new FileOutputStream(new File("/Users//susie//Downloads//ExcelExport.xlsx")); + outputStream = new FileOutputStream(new File("D://tttt//1528.xlsx")); StreamExcel2007Exporter ExcelExport1 = new StreamExcel2007Exporter(); ExcelExport1.export(outputStream, workbook.execute(parameterMap, new WriteActor())); - // 将结果工作薄导出为Word文件 - outputStream = new FileOutputStream(new File("/Users//susie//Downloads//WordExport.doc")); - WordExporter WordExport = new WordExporter(); - WordExport.export(outputStream, workbook.execute(parameterMap, new WriteActor())); - // 将结果工作薄导出为Pdf文件 - outputStream = new FileOutputStream(new File("/Users//susie//Downloads//PdfExport.pdf")); - PDFExporter PdfExport = new PDFExporter(); - PdfExport.export(outputStream, workbook.execute(parameterMap, new WriteActor())); - // 将结果工作薄导出为Txt文件(txt文件本身不支持表格、图表等,被导出模板一般为明细表) - outputStream = new FileOutputStream(new File("/Users//susie//Downloads//TxtExport.txt")); - TextExporter TxtExport = new TextExporter(); - TxtExport.export(outputStream, workbook.execute(parameterMap, new WriteActor())); - // 将结果工作薄导出为Csv文件 - outputStream = new FileOutputStream(new File("/Users//susie//Downloads//CsvExport.csv")); - CSVExporter CsvExport = new CSVExporter(); - CsvExport.export(outputStream, workbook.execute(parameterMap, new WriteActor())); - //将结果工作薄导出为SVG文件 - outputStream = new FileOutputStream(new File("/Users//susie//Downloads//SvgExport.svg")); - SVGExporter SvgExport = new SVGExporter(); - SvgExport.export(outputStream, workbook.execute(parameterMap, new WriteActor())); - //将结果工作薄导出为image文件 - outputStream = new FileOutputStream(new File("/Users//susie//Downloads//PngExport.png")); - ImageExporter ImageExport = new ImageExporter(); - ImageExport.export(outputStream, workbook.execute(parameterMap, new WriteActor())); +// // 将结果工作薄导出为Word文件 +// outputStream = new FileOutputStream(new File("/Users//susie//Downloads//WordExport.doc")); +// WordExporter WordExport = new WordExporter(); +// WordExport.export(outputStream, workbook.execute(parameterMap, new WriteActor())); +// // 将结果工作薄导出为Pdf文件 +// outputStream = new FileOutputStream(new File("/Users//susie//Downloads//PdfExport.pdf")); +// PDFExporter PdfExport = new PDFExporter(); +// PdfExport.export(outputStream, workbook.execute(parameterMap, new WriteActor())); +// // 将结果工作薄导出为Txt文件(txt文件本身不支持表格、图表等,被导出模板一般为明细表) +// outputStream = new FileOutputStream(new File("/Users//susie//Downloads//TxtExport.txt")); +// TextExporter TxtExport = new TextExporter(); +// TxtExport.export(outputStream, workbook.execute(parameterMap, new WriteActor())); +// // 将结果工作薄导出为Csv文件 +// outputStream = new FileOutputStream(new File("/Users//susie//Downloads//CsvExport.csv")); +// CSVExporter CsvExport = new CSVExporter(); +// CsvExport.export(outputStream, workbook.execute(parameterMap, new WriteActor())); +// //将结果工作薄导出为SVG文件 +// outputStream = new FileOutputStream(new File("/Users//susie//Downloads//SvgExport.svg")); +// SVGExporter SvgExport = new SVGExporter(); +// SvgExport.export(outputStream, workbook.execute(parameterMap, new WriteActor())); +// //将结果工作薄导出为image文件 +// outputStream = new FileOutputStream(new File("/Users//susie//Downloads//PngExport.png")); +// ImageExporter ImageExport = new ImageExporter(); +// ImageExport.export(outputStream, workbook.execute(parameterMap, new WriteActor())); outputStream.close(); module.stop(); } catch (Exception e) { diff --git a/src/main/java/com/fr/io/ExportBatch.java b/src/main/java/com/fr/io/ExportBatch.java index 07b3e66..8ad3494 100644 --- a/src/main/java/com/fr/io/ExportBatch.java +++ b/src/main/java/com/fr/io/ExportBatch.java @@ -15,6 +15,7 @@ import com.fr.module.tool.ActivatorToolBox; import com.fr.report.ReportActivator; import com.fr.report.RestrictionActivator; import com.fr.report.module.ReportBaseActivator; +import com.fr.report.write.WriteActivator; import com.fr.scheduler.SchedulerActivator; import com.fr.stable.StableUtils; import com.fr.stable.WriteActor; @@ -38,11 +39,12 @@ public class ExportBatch { new ConfigurationActivator(), new StandaloneModeActivator(), new StateServerActivator(), + new ChartBaseActivator(), new SchedulerActivator(), new ReportBaseActivator(), new RestrictionActivator(), new ReportActivator(), - new ChartBaseActivator()); + new WriteActivator()); SimpleWork.supply(CommonOperator.class, new CommonOperatorImpl()); String envpath = "//Applications//FineReport10_325//webapps//webroot//WEB-INF";//工程路径 SimpleWork.checkIn(envpath); diff --git a/src/main/java/com/fr/io/ExportExcel.java b/src/main/java/com/fr/io/ExportExcel.java index 1b26795..cba3a1b 100644 --- a/src/main/java/com/fr/io/ExportExcel.java +++ b/src/main/java/com/fr/io/ExportExcel.java @@ -23,6 +23,7 @@ import com.fr.report.ReportActivator; import com.fr.report.RestrictionActivator; import com.fr.report.core.ReportUtils; import com.fr.report.module.ReportBaseActivator; +import com.fr.report.write.WriteActivator; import com.fr.scheduler.SchedulerActivator; import com.fr.stable.WriteActor; import com.fr.store.StateServerActivator; @@ -40,11 +41,12 @@ public class ExportExcel { new ConfigurationActivator(), new StandaloneModeActivator(), new StateServerActivator(), + new ChartBaseActivator(), new SchedulerActivator(), new ReportBaseActivator(), new RestrictionActivator(), new ReportActivator(), - new ChartBaseActivator()); + new WriteActivator()); SimpleWork.supply(CommonOperator.class, new CommonOperatorImpl()); String envpath = "//Applications//FineReport10_325//webapps//webroot//WEB-INF";//工程路径 SimpleWork.checkIn(envpath); diff --git a/src/main/java/com/fr/io/ExportReports.java b/src/main/java/com/fr/io/ExportReports.java index 46ea413..ca75b62 100644 --- a/src/main/java/com/fr/io/ExportReports.java +++ b/src/main/java/com/fr/io/ExportReports.java @@ -18,6 +18,7 @@ import com.fr.report.RestrictionActivator; import com.fr.report.core.ReportUtils; import com.fr.report.module.ReportBaseActivator; import com.fr.report.report.PageReport; +import com.fr.report.write.WriteActivator; import com.fr.scheduler.SchedulerActivator; import com.fr.stable.PageActor; import com.fr.store.StateServerActivator; @@ -35,11 +36,12 @@ public class ExportReports { new ConfigurationActivator(), new StandaloneModeActivator(), new StateServerActivator(), + new ChartBaseActivator(), new SchedulerActivator(), new ReportBaseActivator(), new RestrictionActivator(), new ReportActivator(), - new ChartBaseActivator()); + new WriteActivator()); SimpleWork.supply(CommonOperator.class, new CommonOperatorImpl()); String envpath = "//Applications//FineReport10_325//webapps//webroot//WEB-INF";//工程路径 SimpleWork.checkIn(envpath); diff --git a/src/main/java/com/fr/io/JavaPrint.java b/src/main/java/com/fr/io/JavaPrint.java index 95d357e..06b263a 100644 --- a/src/main/java/com/fr/io/JavaPrint.java +++ b/src/main/java/com/fr/io/JavaPrint.java @@ -15,6 +15,7 @@ import com.fr.print.PrintUtils; import com.fr.report.ReportActivator; import com.fr.report.RestrictionActivator; import com.fr.report.module.ReportBaseActivator; +import com.fr.report.write.WriteActivator; import com.fr.scheduler.SchedulerActivator; import com.fr.store.StateServerActivator; import com.fr.workspace.simple.SimpleWork; @@ -29,11 +30,12 @@ public class JavaPrint { new ConfigurationActivator(), new StandaloneModeActivator(), new StateServerActivator(), + new ChartBaseActivator(), new SchedulerActivator(), new ReportBaseActivator(), new RestrictionActivator(), new ReportActivator(), - new ChartBaseActivator()); + new WriteActivator()); SimpleWork.supply(CommonOperator.class, new CommonOperatorImpl()); String envpath = "//Applications//FineReport10_325//webapps//webroot//WEB-INF";//工程路径 SimpleWork.checkIn(envpath); diff --git a/src/main/java/com/fr/io/SaveReportToDatabase.java b/src/main/java/com/fr/io/SaveReportToDatabase.java index 7f62870..2bc2500 100644 --- a/src/main/java/com/fr/io/SaveReportToDatabase.java +++ b/src/main/java/com/fr/io/SaveReportToDatabase.java @@ -12,6 +12,7 @@ import com.fr.module.tool.ActivatorToolBox; import com.fr.report.ReportActivator; import com.fr.report.RestrictionActivator; import com.fr.report.module.ReportBaseActivator; +import com.fr.report.write.WriteActivator; import com.fr.scheduler.SchedulerActivator; import com.fr.store.StateServerActivator; import com.fr.workspace.simple.SimpleWork; @@ -45,11 +46,12 @@ public class SaveReportToDatabase { new ConfigurationActivator(), new StandaloneModeActivator(), new StateServerActivator(), + new ChartBaseActivator(), new SchedulerActivator(), new ReportBaseActivator(), new RestrictionActivator(), new ReportActivator(), - new ChartBaseActivator()); + new WriteActivator()); SimpleWork.supply(CommonOperator.class, new CommonOperatorImpl()); String envpath = "//Applications//FineReport10_325//webapps//webroot//WEB-INF";//工程路径 SimpleWork.checkIn(envpath); diff --git a/src/main/java/com/fr/io/SetParameterWindow.java b/src/main/java/com/fr/io/SetParameterWindow.java index 1cf3466..fa2638e 100644 --- a/src/main/java/com/fr/io/SetParameterWindow.java +++ b/src/main/java/com/fr/io/SetParameterWindow.java @@ -17,6 +17,7 @@ import com.fr.module.tool.ActivatorToolBox; import com.fr.report.ReportActivator; import com.fr.report.RestrictionActivator; import com.fr.report.module.ReportBaseActivator; +import com.fr.report.write.WriteActivator; import com.fr.scheduler.SchedulerActivator; import com.fr.store.StateServerActivator; import com.fr.workspace.simple.SimpleWork; @@ -33,11 +34,12 @@ public class SetParameterWindow { new ConfigurationActivator(), new StandaloneModeActivator(), new StateServerActivator(), + new ChartBaseActivator(), new SchedulerActivator(), new ReportBaseActivator(), new RestrictionActivator(), new ReportActivator(), - new ChartBaseActivator()); + new WriteActivator()); SimpleWork.supply(CommonOperator.class, new CommonOperatorImpl()); String envpath = "//Applications//FineReport10_325//webapps//webroot//WEB-INF";//工程路径 SimpleWork.checkIn(envpath); diff --git a/src/main/java/com/fr/io/SimpleDemo.java b/src/main/java/com/fr/io/SimpleDemo.java index 1ec7f41..bed0132 100644 --- a/src/main/java/com/fr/io/SimpleDemo.java +++ b/src/main/java/com/fr/io/SimpleDemo.java @@ -17,6 +17,7 @@ import com.fr.report.RestrictionActivator; import com.fr.report.cell.CellElement; import com.fr.report.elementcase.TemplateElementCase; import com.fr.report.module.ReportBaseActivator; +import com.fr.report.write.WriteActivator; import com.fr.scheduler.SchedulerActivator; import com.fr.store.StateServerActivator; import com.fr.workspace.simple.SimpleWork; @@ -33,11 +34,12 @@ public class SimpleDemo { new ConfigurationActivator(), new StandaloneModeActivator(), new StateServerActivator(), + new ChartBaseActivator(), new SchedulerActivator(), new ReportBaseActivator(), new RestrictionActivator(), new ReportActivator(), - new ChartBaseActivator()); + new WriteActivator()); SimpleWork.supply(CommonOperator.class, new CommonOperatorImpl()); String envpath = "//Applications//FineReport10_325//webapps//webroot//WEB-INF";//工程路径 SimpleWork.checkIn(envpath); diff --git a/src/test/java/WEB-INF/assist/phantomjs/lib/format.js b/src/test/main/java/WEB-INF/assist/phantomjs/lib/format.js similarity index 100% rename from src/test/java/WEB-INF/assist/phantomjs/lib/format.js rename to src/test/main/java/WEB-INF/assist/phantomjs/lib/format.js diff --git a/src/test/java/WEB-INF/assist/phantomjs/lib/van-convert.js b/src/test/main/java/WEB-INF/assist/phantomjs/lib/van-convert.js similarity index 100% rename from src/test/java/WEB-INF/assist/phantomjs/lib/van-convert.js rename to src/test/main/java/WEB-INF/assist/phantomjs/lib/van-convert.js diff --git a/src/test/java/WEB-INF/assist/phantomjs/lib/vancharts-all.js b/src/test/main/java/WEB-INF/assist/phantomjs/lib/vancharts-all.js similarity index 100% rename from src/test/java/WEB-INF/assist/phantomjs/lib/vancharts-all.js rename to src/test/main/java/WEB-INF/assist/phantomjs/lib/vancharts-all.js diff --git a/src/test/java/WEB-INF/assist/phantomjs/phantomjs-linux32/ChangeLog b/src/test/main/java/WEB-INF/assist/phantomjs/phantomjs-linux32/ChangeLog similarity index 100% rename from src/test/java/WEB-INF/assist/phantomjs/phantomjs-linux32/ChangeLog rename to src/test/main/java/WEB-INF/assist/phantomjs/phantomjs-linux32/ChangeLog diff --git a/src/test/java/WEB-INF/assist/phantomjs/phantomjs-linux32/LICENSE.BSD b/src/test/main/java/WEB-INF/assist/phantomjs/phantomjs-linux32/LICENSE.BSD similarity index 100% rename from src/test/java/WEB-INF/assist/phantomjs/phantomjs-linux32/LICENSE.BSD rename to src/test/main/java/WEB-INF/assist/phantomjs/phantomjs-linux32/LICENSE.BSD diff --git a/src/test/java/WEB-INF/assist/phantomjs/phantomjs-linux32/README.md b/src/test/main/java/WEB-INF/assist/phantomjs/phantomjs-linux32/README.md similarity index 100% rename from src/test/java/WEB-INF/assist/phantomjs/phantomjs-linux32/README.md rename to src/test/main/java/WEB-INF/assist/phantomjs/phantomjs-linux32/README.md diff --git a/src/test/java/WEB-INF/assist/phantomjs/phantomjs-linux32/bin/phantomjs b/src/test/main/java/WEB-INF/assist/phantomjs/phantomjs-linux32/bin/phantomjs similarity index 100% rename from src/test/java/WEB-INF/assist/phantomjs/phantomjs-linux32/bin/phantomjs rename to src/test/main/java/WEB-INF/assist/phantomjs/phantomjs-linux32/bin/phantomjs diff --git a/src/test/java/WEB-INF/assist/phantomjs/phantomjs-linux32/third-party.txt b/src/test/main/java/WEB-INF/assist/phantomjs/phantomjs-linux32/third-party.txt similarity index 100% rename from src/test/java/WEB-INF/assist/phantomjs/phantomjs-linux32/third-party.txt rename to src/test/main/java/WEB-INF/assist/phantomjs/phantomjs-linux32/third-party.txt diff --git a/src/test/java/WEB-INF/assist/phantomjs/phantomjs-linux64/ChangeLog b/src/test/main/java/WEB-INF/assist/phantomjs/phantomjs-linux64/ChangeLog similarity index 100% rename from src/test/java/WEB-INF/assist/phantomjs/phantomjs-linux64/ChangeLog rename to src/test/main/java/WEB-INF/assist/phantomjs/phantomjs-linux64/ChangeLog diff --git a/src/test/java/WEB-INF/assist/phantomjs/phantomjs-linux64/LICENSE.BSD b/src/test/main/java/WEB-INF/assist/phantomjs/phantomjs-linux64/LICENSE.BSD similarity index 100% rename from src/test/java/WEB-INF/assist/phantomjs/phantomjs-linux64/LICENSE.BSD rename to src/test/main/java/WEB-INF/assist/phantomjs/phantomjs-linux64/LICENSE.BSD diff --git a/src/test/java/WEB-INF/assist/phantomjs/phantomjs-linux64/README.md b/src/test/main/java/WEB-INF/assist/phantomjs/phantomjs-linux64/README.md similarity index 100% rename from src/test/java/WEB-INF/assist/phantomjs/phantomjs-linux64/README.md rename to src/test/main/java/WEB-INF/assist/phantomjs/phantomjs-linux64/README.md diff --git a/src/test/java/WEB-INF/assist/phantomjs/phantomjs-linux64/bin/phantomjs b/src/test/main/java/WEB-INF/assist/phantomjs/phantomjs-linux64/bin/phantomjs similarity index 100% rename from src/test/java/WEB-INF/assist/phantomjs/phantomjs-linux64/bin/phantomjs rename to src/test/main/java/WEB-INF/assist/phantomjs/phantomjs-linux64/bin/phantomjs diff --git a/src/test/java/WEB-INF/assist/phantomjs/phantomjs-linux64/third-party.txt b/src/test/main/java/WEB-INF/assist/phantomjs/phantomjs-linux64/third-party.txt similarity index 100% rename from src/test/java/WEB-INF/assist/phantomjs/phantomjs-linux64/third-party.txt rename to src/test/main/java/WEB-INF/assist/phantomjs/phantomjs-linux64/third-party.txt diff --git a/src/test/java/WEB-INF/assist/phantomjs/phantomjs-macos/ChangeLog b/src/test/main/java/WEB-INF/assist/phantomjs/phantomjs-macos/ChangeLog similarity index 100% rename from src/test/java/WEB-INF/assist/phantomjs/phantomjs-macos/ChangeLog rename to src/test/main/java/WEB-INF/assist/phantomjs/phantomjs-macos/ChangeLog diff --git a/src/test/java/WEB-INF/assist/phantomjs/phantomjs-macos/LICENSE.BSD b/src/test/main/java/WEB-INF/assist/phantomjs/phantomjs-macos/LICENSE.BSD similarity index 100% rename from src/test/java/WEB-INF/assist/phantomjs/phantomjs-macos/LICENSE.BSD rename to src/test/main/java/WEB-INF/assist/phantomjs/phantomjs-macos/LICENSE.BSD diff --git a/src/test/java/WEB-INF/assist/phantomjs/phantomjs-macos/README.md b/src/test/main/java/WEB-INF/assist/phantomjs/phantomjs-macos/README.md similarity index 100% rename from src/test/java/WEB-INF/assist/phantomjs/phantomjs-macos/README.md rename to src/test/main/java/WEB-INF/assist/phantomjs/phantomjs-macos/README.md diff --git a/src/test/java/WEB-INF/assist/phantomjs/phantomjs-macos/bin/phantomjs b/src/test/main/java/WEB-INF/assist/phantomjs/phantomjs-macos/bin/phantomjs similarity index 100% rename from src/test/java/WEB-INF/assist/phantomjs/phantomjs-macos/bin/phantomjs rename to src/test/main/java/WEB-INF/assist/phantomjs/phantomjs-macos/bin/phantomjs diff --git a/src/test/java/WEB-INF/assist/phantomjs/phantomjs-macos/third-party.txt b/src/test/main/java/WEB-INF/assist/phantomjs/phantomjs-macos/third-party.txt similarity index 100% rename from src/test/java/WEB-INF/assist/phantomjs/phantomjs-macos/third-party.txt rename to src/test/main/java/WEB-INF/assist/phantomjs/phantomjs-macos/third-party.txt diff --git a/src/test/java/WEB-INF/assist/phantomjs/phantomjs-windows/ChangeLog b/src/test/main/java/WEB-INF/assist/phantomjs/phantomjs-windows/ChangeLog similarity index 100% rename from src/test/java/WEB-INF/assist/phantomjs/phantomjs-windows/ChangeLog rename to src/test/main/java/WEB-INF/assist/phantomjs/phantomjs-windows/ChangeLog diff --git a/src/test/java/WEB-INF/assist/phantomjs/phantomjs-windows/LICENSE.BSD b/src/test/main/java/WEB-INF/assist/phantomjs/phantomjs-windows/LICENSE.BSD similarity index 100% rename from src/test/java/WEB-INF/assist/phantomjs/phantomjs-windows/LICENSE.BSD rename to src/test/main/java/WEB-INF/assist/phantomjs/phantomjs-windows/LICENSE.BSD diff --git a/src/test/java/WEB-INF/assist/phantomjs/phantomjs-windows/README.md b/src/test/main/java/WEB-INF/assist/phantomjs/phantomjs-windows/README.md similarity index 100% rename from src/test/java/WEB-INF/assist/phantomjs/phantomjs-windows/README.md rename to src/test/main/java/WEB-INF/assist/phantomjs/phantomjs-windows/README.md diff --git a/src/test/java/WEB-INF/assist/phantomjs/phantomjs-windows/bin/phantomjs.exe b/src/test/main/java/WEB-INF/assist/phantomjs/phantomjs-windows/bin/phantomjs.exe similarity index 100% rename from src/test/java/WEB-INF/assist/phantomjs/phantomjs-windows/bin/phantomjs.exe rename to src/test/main/java/WEB-INF/assist/phantomjs/phantomjs-windows/bin/phantomjs.exe diff --git a/src/test/java/WEB-INF/assist/phantomjs/phantomjs-windows/third-party.txt b/src/test/main/java/WEB-INF/assist/phantomjs/phantomjs-windows/third-party.txt similarity index 100% rename from src/test/java/WEB-INF/assist/phantomjs/phantomjs-windows/third-party.txt rename to src/test/main/java/WEB-INF/assist/phantomjs/phantomjs-windows/third-party.txt diff --git a/src/test/java/WEB-INF/assist/phantomjs/phantomjs-winxp/bin/phantomjs.exe b/src/test/main/java/WEB-INF/assist/phantomjs/phantomjs-winxp/bin/phantomjs.exe similarity index 100% rename from src/test/java/WEB-INF/assist/phantomjs/phantomjs-winxp/bin/phantomjs.exe rename to src/test/main/java/WEB-INF/assist/phantomjs/phantomjs-winxp/bin/phantomjs.exe diff --git a/src/test/java/WEB-INF/reportlets/demo.cpt b/src/test/main/java/WEB-INF/reportlets/demo.cpt similarity index 100% rename from src/test/java/WEB-INF/reportlets/demo.cpt rename to src/test/main/java/WEB-INF/reportlets/demo.cpt diff --git a/src/test/main/java/WEB-INF/reportlets/sumtest.cpt b/src/test/main/java/WEB-INF/reportlets/sumtest.cpt new file mode 100644 index 0000000..7226191 --- /dev/null +++ b/src/test/main/java/WEB-INF/reportlets/sumtest.cpt @@ -0,0 +1,51 @@ + + + + +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
diff --git a/src/test/main/java/com/fr/demo/ExportApiTest.java b/src/test/main/java/com/fr/demo/ExportApiTest.java new file mode 100644 index 0000000..ef070bb --- /dev/null +++ b/src/test/main/java/com/fr/demo/ExportApiTest.java @@ -0,0 +1,85 @@ +package com.fr.demo; + +import com.fr.base.operator.common.CommonOperator; +import com.fr.chart.activator.ChartBaseActivator; +import com.fr.cluster.engine.activator.standalone.StandaloneModeActivator; +import com.fr.config.activator.BaseDBActivator; +import com.fr.config.activator.ConfigurationActivator; +import com.fr.env.operator.CommonOperatorImpl; +import com.fr.general.I18nResource; +import com.fr.io.TemplateWorkBookIO; +import com.fr.io.exporter.excel.stream.StreamExcel2007Exporter; +import com.fr.log.FineLoggerFactory; +import com.fr.main.TemplateWorkBook; +import com.fr.main.impl.WorkBook; +import com.fr.main.workbook.ResultWorkBook; +import com.fr.module.Module; +import com.fr.module.tool.ActivatorToolBox; +import com.fr.report.ReportActivator; +import com.fr.report.RestrictionActivator; +import com.fr.report.module.ReportBaseActivator; +import com.fr.report.worksheet.WorkSheet; +import com.fr.report.write.WriteActivator; +import com.fr.scheduler.SchedulerActivator; +import com.fr.stable.WriteActor; +import com.fr.store.StateServerActivator; +import com.fr.workspace.simple.SimpleWork; +import com.fr.write.web.excel.ExcelImportPlusProcessor; +import junit.framework.TestCase; +import org.junit.Assert; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.InputStream; +import java.util.HashMap; + +/** + * @author zack + * @version 10.0 + * @date 2019/8/27 + */ +public class ExportApiTest extends TestCase { + public void testExport() { + Module module = ActivatorToolBox.simpleLink(new BaseDBActivator(), + new ConfigurationActivator(), + new StandaloneModeActivator(), + new StateServerActivator(), + new ChartBaseActivator(), + new SchedulerActivator(), + new ReportBaseActivator(), + new RestrictionActivator(), + new ReportActivator(), + new WriteActivator()); + SimpleWork.supply(CommonOperator.class, new CommonOperatorImpl()); + SimpleWork.checkIn(ExportApiTest.class.getResource("../../../WEB-INF").getPath()); + I18nResource.getInstance(); + module.start(); + + + ResultWorkBook rworkbook = null; + try { + // 未执行模板工作薄 + WorkBook workbook = (WorkBook) TemplateWorkBookIO + .readTemplateWorkBook("//sumtest.cpt"); + // 获取报表参数并设置值,导出内置数据集时数据集会根据参数值查询出结果从而转为内置数据集 + // 定义parametermap用于执行报表,将执行后的结果工作薄保存为rworkBook + java.util.Map parameterMap = new java.util.HashMap(); + // 定义输出流 + ByteArrayOutputStream outputStream; + // 将结果工作薄导出为Excel文件 + outputStream = new ByteArrayOutputStream(); + StreamExcel2007Exporter ExcelExport1 = new StreamExcel2007Exporter(); + ExcelExport1.export(outputStream, workbook.execute(parameterMap, new WriteActor())); + outputStream.close(); + InputStream in = new ByteArrayInputStream(outputStream.toByteArray()); + TemplateWorkBook workBook = new ExcelImportPlusProcessor().generateWorkBookByStream(in, "111.xlsx", new HashMap()); + Assert.assertEquals(6, ((WorkSheet) workBook.getReport(0)).getCellElement(0, 0).getValue()); + Assert.assertEquals(3, ((WorkSheet) workBook.getReport(0)).getCellElement(1, 0).getValue()); + module.stop(); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } finally { + SimpleWork.checkOut(); + } + } +} \ No newline at end of file diff --git a/src/test/java/com/fr/demo/ModuleStartTest.java b/src/test/main/java/com/fr/demo/ModuleStartTest.java similarity index 95% rename from src/test/java/com/fr/demo/ModuleStartTest.java rename to src/test/main/java/com/fr/demo/ModuleStartTest.java index 44d5080..de2cb8a 100644 --- a/src/test/java/com/fr/demo/ModuleStartTest.java +++ b/src/test/main/java/com/fr/demo/ModuleStartTest.java @@ -17,6 +17,7 @@ import com.fr.module.tool.ActivatorToolBox; import com.fr.report.ReportActivator; import com.fr.report.RestrictionActivator; import com.fr.report.module.ReportBaseActivator; +import com.fr.report.write.WriteActivator; import com.fr.scheduler.SchedulerActivator; import com.fr.store.StateServerActivator; import com.fr.workspace.simple.SimpleWork; @@ -65,11 +66,13 @@ public class ModuleStartTest extends TestCase { new ConfigurationActivator(), new StandaloneModeActivator(), new StateServerActivator(), + new ChartBaseActivator(), new SchedulerActivator(), new ReportBaseActivator(), new RestrictionActivator(), new ReportActivator(), - new ChartBaseActivator()); + new WriteActivator() + ); return module; } diff --git a/src/test/java/com/fr/demo/TestLogAppender.java b/src/test/main/java/com/fr/demo/TestLogAppender.java similarity index 100% rename from src/test/java/com/fr/demo/TestLogAppender.java rename to src/test/main/java/com/fr/demo/TestLogAppender.java