I. Overview
Apart from ExcelExporter, i.e. Unaltered Export, which has been covered in the Export section, FineReport offers three additional export methods, namely, Pagination Export, Page to Sheet Export and Large Data Volume Export. The corresponding interfaces are provided to implement these methods in your projects.
1. Unaltered Export (Excel2003)
//Unaltered Export (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()));
2. Unaltered Export (Excel2007)
//Unaltered Export (Excel2007)
outputStream = new FileOutputStream(new File("C:\\test\\ExcelExport.xlsx"));
StreamExcel2007Exporter excel1 = new StreamExcel2007Exporter();
excel.export(outputStream, workbook.execute(parameterMap,new WriteActor()));
3. Pagination Export (Excel2003)
//Pagination Export (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()));
4. Pagination Export (Excel2007)
//Pagination Export (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()));
5. Page to Sheet Export (Excel2003)
//Page to Sheet Export (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()));
6. Page to Sheet Export (Excel2007)
//Page to Sheet Export (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()));
7. Large Data Volume Export
This option will export an archived .xls file with 65512 rows by default.
//Large Data Volume Export
outputStream = new FileOutputStream(new File("C:\\test\\LargeExcelExport.zip"));
LargeDataPageExcelExporter large = new LargeDataPageExcelExporter(ReportUtils.getPaperSettingListFromWorkBook(workbook.execute(parameterMap,new WriteActor())), true);
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()));
II. Example
1. Detailed Executable Codes
Note: the project path needs to be modified accordingly.
As shown below, files with different formats will be created in corresponding paths once you have successfully compiled and run the code.