|
|
@ -30,7 +30,7 @@ import java.io.FileOutputStream; |
|
|
|
|
|
|
|
|
|
|
|
public class ExportApi_frm { |
|
|
|
public class ExportApi_frm { |
|
|
|
public static void main(String[] args) { |
|
|
|
public static void main(String[] args) { |
|
|
|
// 定义报表运行环境,用于执行报表
|
|
|
|
// 定义报表运行环境,用于执行报表
|
|
|
|
Module module = ActivatorToolBox.simpleLink(new BaseDBActivator(), |
|
|
|
Module module = ActivatorToolBox.simpleLink(new BaseDBActivator(), |
|
|
|
new ConfigurationActivator(), |
|
|
|
new ConfigurationActivator(), |
|
|
|
new StandaloneModeActivator(), |
|
|
|
new StandaloneModeActivator(), |
|
|
@ -42,72 +42,26 @@ public class ExportApi_frm { |
|
|
|
new WriteActivator(), |
|
|
|
new WriteActivator(), |
|
|
|
new ChartBaseActivator()); |
|
|
|
new ChartBaseActivator()); |
|
|
|
SimpleWork.supply(CommonOperator.class, new CommonOperatorImpl()); |
|
|
|
SimpleWork.supply(CommonOperator.class, new CommonOperatorImpl()); |
|
|
|
String envpath = "C:\\Users\\hipsh\\Desktop\\apache-tomcat-8.5.38-10.0\\webapps\\webroot\\WEB-INF\\";//工程路径
|
|
|
|
String envpath = "C:\\Users\\hipsh\\Desktop\\apache-tomcat-8.5.38-10.0\\webapps\\webroot\\WEB-INF\\";//工程路径
|
|
|
|
SimpleWork.checkIn(envpath); |
|
|
|
SimpleWork.checkIn(envpath); |
|
|
|
I18nResource.getInstance(); |
|
|
|
I18nResource.getInstance(); |
|
|
|
module.start(); |
|
|
|
module.start(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ResultWorkBook rworkbook = null;
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
// 导出cpt,未执行模板工作薄
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// WorkBook workbook = (WorkBook) TemplateWorkBookIO
|
|
|
|
|
|
|
|
// .readTemplateWorkBook("测试模板.frm");
|
|
|
|
|
|
|
|
// 获取报表参数并设置值,导出内置数据集时数据集会根据参数值查询出结果从而转为内置数据集
|
|
|
|
|
|
|
|
// Parameter[] parameters = workbook.getParameters();
|
|
|
|
|
|
|
|
// parameters[0].setValue("华东");
|
|
|
|
|
|
|
|
// 定义parametermap用于执行报表,将执行后的结果工作薄保存为rworkBook
|
|
|
|
|
|
|
|
java.util.Map parameterMap = new java.util.HashMap(); |
|
|
|
java.util.Map parameterMap = new java.util.HashMap(); |
|
|
|
parameterMap.put("aa", "1"); |
|
|
|
parameterMap.put("aa", "1"); |
|
|
|
// for (int i = 0; i < parameters.length; i++) {
|
|
|
|
|
|
|
|
// parameterMap.put(parameters[i].getName(), parameters[i]
|
|
|
|
|
|
|
|
// .getValue());
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//导出frm时用这个
|
|
|
|
|
|
|
|
ResultWorkBook re = FormToWBExecutor.executeForm("test.frm",parameterMap); |
|
|
|
ResultWorkBook re = FormToWBExecutor.executeForm("test.frm",parameterMap); |
|
|
|
// 定义输出流
|
|
|
|
// 定义输出流
|
|
|
|
FileOutputStream outputStream; |
|
|
|
FileOutputStream outputStream; |
|
|
|
// // 将未执行模板工作薄导出为内置数据集模板
|
|
|
|
// 将结果工作薄导出为Excel文件
|
|
|
|
// 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("C:\\FTPServer\\1528.xlsx")); |
|
|
|
outputStream = new FileOutputStream(new File("C:\\FTPServer\\1528.xlsx")); |
|
|
|
StreamExcel2007Exporter ExcelExport1 = new StreamExcel2007Exporter(); |
|
|
|
StreamExcel2007Exporter ExcelExport1 = new StreamExcel2007Exporter(); |
|
|
|
//ResultWorkBook re = FSFormletHandler.executeForm("calendar.frm",parameterMap);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//ResultWorkBook re = FSFormletHandler.executeForm("test.frm",parameterMap);
|
|
|
|
|
|
|
|
// ExcelExport1.export(outputStream, workbook.execute(parameterMap, new WriteActor()));
|
|
|
|
|
|
|
|
ExcelExport1.export(outputStream,re); |
|
|
|
ExcelExport1.export(outputStream,re); |
|
|
|
// // 将结果工作薄导出为Word文件
|
|
|
|
// 将结果工作薄导出为Pdf文件
|
|
|
|
// 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("C:\\FTPServer\\PdfExport.pdf")); |
|
|
|
outputStream = new FileOutputStream(new File("C:\\FTPServer\\PdfExport.pdf")); |
|
|
|
PDFExporter PdfExport = new PDFExporter(); |
|
|
|
PDFExporter PdfExport = new PDFExporter(); |
|
|
|
PdfExport.export(outputStream, re); |
|
|
|
PdfExport.export(outputStream, re); |
|
|
|
// // 将结果工作薄导出为Txt文件(txt文件本身不支持表格、图表等,被导出模板一般为明细表)
|
|
|
|
//将结果工作薄导出为image文件
|
|
|
|
// 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("C:\\FTPServer\\PngExport.png")); |
|
|
|
outputStream = new FileOutputStream(new File("C:\\FTPServer\\PngExport.png")); |
|
|
|
ImageExporter ImageExport = new ImageExporter(); |
|
|
|
ImageExporter ImageExport = new ImageExporter(); |
|
|
|
ImageExport.export(outputStream, re); |
|
|
|
ImageExport.export(outputStream, re); |
|
|
|