反饋已提交
網絡繁忙
在导出章节中我们介绍了 Excel 导出方式 ExcelExporter,此为原样导出。若是您先前学习过 FineReport 学习教程,您会知道,在 FineReport 中,除原样导出外还有另外三种导出方式:分页导出、分页分 sheet 导出、大数据量导出。在程序中有不同的接口来实现:
//原样导出excel2003 outputStream = new FileOutputStream(new File("C:\\test\\ExcelExport.xls")); ExcelExporter excel = new ExcelExporter(); excel.setVersion(true); excel.export(outputStream, workbook.execute(parameterMap,new WriteActor()));
//原样导出excel2007 outputStream = new FileOutputStream(new File("C:\\test\\ExcelExport.xlsx")); StreamExcel2007Exporter excel1 = new StreamExcel2007Exporter(); excel.export(outputStream, workbook.execute(parameterMap,new WriteActor()));
//分页导出excel2003 outputStream = new FileOutputStream(new File("C:\\test\\PageExcelExport.xls")); PageExcelExporter page = new PageExcelExporter(ReportUtils.getPaperSettingListFromWorkBook(workbook.execute(parameterMap,new WriteActor()))); page.setVersion(true); page.export(outputStream, workbook.execute(parameterMap,new WriteActor()));
//分页导出excel2007 outputStream = new FileOutputStream(new File("C:\\test\\PageExcelExport.xlsx")); PageExcel2007Exporter page1 = new PageExcel2007Exporter(ReportUtils.getPaperSettingListFromWorkBook(rworkbook)); page1.export(outputStream, workbook.execute(parameterMap,new WriteActor()));
//分页分sheet导出excel2003 outputStream = new FileOutputStream(new File("C:\\test\\PageSheetExcelExport.xls")); PageToSheetExcelExporter sheet = new PageToSheetExcelExporter(ReportUtils.getPaperSettingListFromWorkBook(workbook.execute(parameterMap,new WriteActor()))); sheet.setVersion(true); sheet.export(outputStream, workbook.execute(parameterMap,new WriteActor()));
//分页分sheet导出excel2007 outputStream = new FileOutputStream(new File("C:\\test\\PageSheetExcelExport.xlsx")); PageToSheetExcel2007Exporter sheet1 = new PageToSheetExcel2007Exporter(ReportUtils.getPaperSettingListFromWorkBook(rworkbook)); sheet1.export(outputStream, workbook.execute(parameterMap,new WriteActor()));
大数据量导出默认是 65512 行的 .xls 组成的压缩包
//大数据量导出 outputStream = new FileOutputStream(new File("C:\\test\\LargeExcelExport.zip")); LargeDataPageExcelExporter large = new LargeDataPageExcelExporter(ReportUtils.getPaperSettingListFromWorkBook(workbook.execute(parameterMap,new WriteActor())), true); //导出2007版outputStream = new FileOutputStream(new File("C:\\test\\LargeExcelExport.xlsx")); LargeDataPageExcel2007Exporter large = new LargeDataPageExcel2007Exporter(ReportUtils.getPaperSettingListFromWorkBook(rworkbook), true); large.export(outputStream, workbook.execute(parameterMap,new WriteActor()));
https://code.fanruan.com/demo/example/src/release/10.0/src/main/java/com/fr/io/ExportExcel.java
注:工程路径需要根据实际情况修改
编译运行该代码后,就会在对应路径下生成不同格式的文件,这样就导出成功了,如下图:
文 檔回 饋
滑鼠選中內容,快速回饋問題
滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。
不再提示
10s後關閉