帆软后台下载 main

╰+攻爆jí腚メ 2022-01-07 02:21 459阅读 0赞
  1. package avicit;
  2. import java.io.File;
  3. import java.io.FileOutputStream;
  4. import javax.servlet.http.HttpServletRequest;
  5. import com.fr.base.FRContext;
  6. import com.fr.dav.LocalEnv;
  7. import com.fr.general.ModuleContext;
  8. import com.fr.io.TemplateWorkBookIO;
  9. import com.fr.io.exporter.CSVExporter;
  10. import com.fr.io.exporter.EmbeddedTableDataExporter;
  11. import com.fr.io.exporter.ExcelExporter;
  12. import com.fr.io.exporter.ImageExporter;
  13. import com.fr.io.exporter.PDFExporterProcessor;
  14. import com.fr.io.exporter.SVGExporter;
  15. import com.fr.io.exporter.TextExporter;
  16. import com.fr.io.exporter.WordExporter;
  17. import com.fr.io.exporter.excel.stream.StreamExcel2007Exporter;
  18. import com.fr.main.impl.WorkBook;
  19. import com.fr.main.workbook.ResultWorkBook;
  20. import com.fr.report.module.EngineModule;
  21. import com.fr.stable.WriteActor;
  22. import com.fr.web.core.reserve.PDFExporterFactory;
  23. public class ExportApi {
  24. public static void main(String[] args) {
  25. // 定义报表运行环境,才能执行报表
  26. //String envpath = request.getRealPath("WEB-INF");
  27. String envpath = "E:\\workSpace\\v6\\PlatformWebappPro\\src\\main\\webapp\\WEB-INF";
  28. FRContext.setCurrentEnv(new LocalEnv(envpath));
  29. ModuleContext.startModule(EngineModule.class.getName());
  30. ResultWorkBook rworkbook = null;
  31. try {
  32. // 未执行模板工作薄
  33. WorkBook workbook = (WorkBook) TemplateWorkBookIO.readTemplateWorkBook(FRContext.getCurrentEnv(), "\\test.cpt");
  34. // 获取报表参数并设置值,导出内置数据集时数据集会根据参数值查询出结果从而转为内置数据集
  35. int i = 1;
  36. while (i <= 3) {
  37. i++;
  38. // 定义parametermap用于执行报表,将执行后的结果工作薄保存为rworkBook
  39. java.util.Map parameterMap = new java.util.HashMap();
  40. parameterMap.put("mesEwoId", "");
  41. // 定义输出流
  42. FileOutputStream outputStream;
  43. // 将未执行模板工作薄导出为内置数据集模板
  44. outputStream = new FileOutputStream(new File("D:\\1\\EmbExport_"+i+".cpt"));
  45. EmbeddedTableDataExporter templateExporter = new EmbeddedTableDataExporter();
  46. templateExporter.export(outputStream, workbook);
  47. // 将模板工作薄导出模板文件,在导出前您可以编辑导入的模板工作薄,可参考报表调用章节
  48. outputStream = new FileOutputStream(new File("D:\\1\\TmpExport_"+i+".cpt"));
  49. ((WorkBook) workbook).export(outputStream);
  50. // 将结果工作薄导出为2003Excel文件
  51. outputStream = new FileOutputStream(new File("D:\\1\\ExcelExport_"+i+".xls"));
  52. ExcelExporter ExcelExport = new ExcelExporter();
  53. ExcelExport.export(outputStream, workbook.execute(parameterMap, new WriteActor()));
  54. // 将结果工作薄导出为Excel文件
  55. outputStream = new FileOutputStream(new File("D:\\1\\ExcelExport_"+i+".xlsx"));
  56. StreamExcel2007Exporter ExcelExport1 = new StreamExcel2007Exporter();
  57. ExcelExport1.export(outputStream, workbook.execute(parameterMap, new WriteActor()));
  58. // 将结果工作薄导出为Word文件
  59. outputStream = new FileOutputStream(new File("D:\\1\\WordExport_"+i+".doc"));
  60. WordExporter WordExport = new WordExporter();
  61. WordExport.export(outputStream, workbook.execute(parameterMap, new WriteActor()));
  62. // 将结果工作薄导出为Pdf文件
  63. outputStream = new FileOutputStream(new File("D:\\1\\PdfExport_"+i+".pdf"));
  64. PDFExporterProcessor PdfExport = PDFExporterFactory.getPDFExporter();
  65. PdfExport.export(outputStream, workbook.execute(parameterMap, new WriteActor()));
  66. // 将结果工作薄导出为Txt文件(txt文件本身不支持表格、图表等,被导出模板一般为明细表)
  67. outputStream = new FileOutputStream(new File("D:\\1\\TxtExport_"+i+".txt"));
  68. TextExporter TxtExport = new TextExporter();
  69. TxtExport.export(outputStream, workbook.execute(parameterMap, new WriteActor()));
  70. // 将结果工作薄导出为Csv文件
  71. outputStream = new FileOutputStream(new File("D:\\1\\CsvExport_"+i+".csv"));
  72. CSVExporter CsvExport = new CSVExporter();
  73. CsvExport.export(outputStream, workbook.execute(parameterMap, new WriteActor()));
  74. // 将结果工作薄导出为SVG文件
  75. outputStream = new FileOutputStream(new File("D:\\1\\SvgExport_"+i+".svg"));
  76. SVGExporter SvgExport = new SVGExporter();
  77. SvgExport.export(outputStream, workbook.execute(parameterMap, new WriteActor()));
  78. // 将结果工作薄导出为image文件
  79. outputStream = new FileOutputStream(new File("D:\\1\\PngExport_"+i+".png"));
  80. ImageExporter ImageExport = new ImageExporter();
  81. ImageExport.export(outputStream, workbook.execute(parameterMap, new WriteActor()));
  82. outputStream.close();
  83. ModuleContext.stopModules();
  84. }
  85. } catch (Exception e) {
  86. e.printStackTrace();
  87. }
  88. }
  89. }

发表评论

表情:
评论列表 (有 0 条评论,459人围观)

还没有评论,来说两句吧...

相关阅读

    相关 文本函数

    1. CHAR   CHAR(number):根据指定数字代码返回对应的字符。CHAR 函数可将计算机其他类型的数字代码转换为字符。 Number:用于指定字符的数字

    相关 01-简单入门

    前言 FineReport是由帆软自主研发的一款纯Java编写的报表软件产品,集数据展示(报表)和数据录入(表单)功能于一身,能够制作复杂的报表,操作简单易用。针对软件开