Java Reporting Tools Finereport Export four of Excel APIs

Source: Internet
Author: User

in real-world applications, it is often necessary to export data intoExcel, the exported method is exported in addition to thePagination export, pagingSheetExport and large data volume export. ForExcel 2003due to limitations on eachsheetthe maximum number of rows and columns, and when large data is exported, it will default to multiplesheet, whileexcel2007There is no such problem. These export methods areJavathere are different interfaces in the program to achieve:

1. export AS-is

export as is without previewing direct export Excel

Its program interface code is as follows:

OutputStream = new FileOutputStream (New File ("E:\\excelexport.xls"));   Excelexporter Excel = new Excelexporter ();  Export version 2007 OutputStream = new FileOutputStream (New File ("e:\\excelexport.xlsx")); Excel excel2007exporter Excel = new Excel2007exporter (); Excel.export (OutputStream, Rworkbook);

:


650) this.width=650; "Src=" http://dl2.iteye.com/upload/attachment/0115/8079/ D72977e4-b01c-3ad5-8f57-64d7b69193e3.png "style=" border:0px; "/>

2. Paging Export

Page export, if the report template is paginated, it will be exported according to the results of pagination, duplicate headings and so on will be repeated.

Its program interface code is as follows:

OutputStream = new FileOutputStream (New File ("E:\\pageexcelexport.xls")); Pageexcelexporter page = new Pageexcelexporter (Reportutils.getpapersettinglistfromworkbook (Rworkbook));//Export version 2007 OutputStream = new FileOutputStream (New File ("e:\\pageexcelexport.xlsx")); Excel pageexcel2007exporter page = new Pageexcel2007exporter (Reportutils.getpapersettinglistfromworkbook (Rworkbook) ); Page.export (OutputStream, Rworkbook);



650) this.width=650; "Src=" http://dl2.iteye.com/upload/attachment/0115/8081/ 44571a3d-5ca9-3534-a3cb-92a9e16d6bc2.png "style=" border:0px; "/>

3. Paging Sub -sheet Export

Sub-page points Sheet each page of the report results when exporting is a Sheet saved in Excel in the file

The code is as follows:

OutputStream = new FileOutputStream (New File ("E:\\pagesheetexcelexport.xls")); Pagetosheetexcelexporter sheet = new Pagetosheetexcelexporter (Reportutils.getpapersettinglistfromworkbook ( Rworkbook)); Export version 2007 OutputStream = new FileOutputStream (New File ("e:\\pagesheetexcelexport.xlsx")); Excel pagetosheetexcel2007exporter sheet = new Pagetosheetexcel2007exporter ( Reportutils.getpapersettinglistfromworkbook (Rworkbook)); Sheet.export (OutputStream, Rworkbook);



650) this.width=650; "Src=" http://dl2.iteye.com/upload/attachment/0115/8083/ B6fff56a-cf40-30cd-91fa-7216f7bf67ca.png "style=" border:0px; "/>

4, large data volume export

This is more common, for example with 50000 behavior of a Excel file

The code is as follows:

OutputStream = new FileOutputStream (New File ("E:\\largeexcelexport.zip")); Largedatapageexcelexporter large = new Largedatapageexcelexporter (Reportutils.getpapersettinglistfromworkbook ( Rworkbook), true); Export version 2007 OutputStream = new FileOutputStream (New File ("e:\\largeexcelexport.xlsx")); Excel largedatapageexcel2007exporter large = new Largedatapageexcel2007exporter ( Reportutils.getpapersettinglistfromworkbook (Rworkbook), true); Large.export (OutputStream, Rworkbook);


There are two things you might see when you export a report with a large volume of data:

    • The export is successful, the data will be displayed in multiple sheet

    • excel

    • no big data-volume report export with row engine enabled

In the absence of a row engine enabled, there are two cases: the server can withstand the export success, the server cannot afford to export failure, the following we see the results:

4.1.1 The server is under range

can withstand the scope is: the volume of data is large, more than the excel The maximum number of rows but not very large, such as 10 excel sheet excel the number of rows and columns is limited, such as excel2003 The maximum number of rows is limited to 65536 column.

4.1.2 server cannot withstand

The amount of data that cannot be sustained is primarily large, and very large, such as hundreds stadiums or even more, and may fail to export due to memory limitations. While exporting the results, open the export failed Excel, whose contents are not valid.

for these two export results, the main reason is the amount of data and data complexity (number of columns) how much, in the absence of a row engine, there will be a critical point, below the critical point when you can export the success of the exported content has more than sheet, otherwise the export failed, the content is invalid. Therefore, for large data volumes, it is common to use the row engine to represent, in which case the export Excel is always successful. When you export Excel in a large data volume report that has the row engine enabled , it is split into multiple . xls files and transferred to the client in a compressed package file format.

4.2 enable the large Data volume report export for the row engine

for large data volume reports, typically using a row engine, in which case the export Excel always succeeds. Because a large data volume report that enables the row engine is exported to Excel , it is split into multiple . xls files and transferred to the client in a compressed package file format.

For example, Big Data reports have 100w rows of data, set up a row engine, and display each page in a row . The result of the export will be a total of four Excel, the first nine Excel each 24990 line, the last Excel Line, eight Excel compression for the zip package to the client download.


Java Reporting Tools Finereport Export four of Excel APIs

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.