Class BigGridDemo


  • public final class BigGridDemo
    extends Object
    Demonstrates a workaround you can use to generate large workbooks and avoid OutOfMemory exception.

    Note - You probably don't want to use this approach any more! POI now includes the SXSSF which handles all of this for you, you should be using that instead! This code remains mostly for historical interest.

    If you really want to use this approach, which is also the one that SXSSF does for you, it works as follows:

    1. create a template workbook, create sheets and global objects such as cell styles, number formats, etc.
    2. create an application that streams data in a text file
    3. Substitute the sheet in the template with the generated data
    Since 3.8 POI provides a low-memory footprint SXSSF API, which implements ths "BigGridDemo" strategy. SXSSF is an API-compatible streaming extension of XSSF to be used when very large spreadsheets have to be produced, and heap space is limited. SXSSF achieves its low memory footprint by limiting access to the rows that are within a sliding window, while XSSF gives access to all rows in the document. Older rows that are no longer in the window become inaccessible, as they are written to the disk. See SXSSF (Streaming Usermodel API).