API to write huge excel files using java

后端 未结 9 697
挽巷
挽巷 2020-12-24 14:36

I am looking to write to an excel (.xls MS Excel 2003 format) file programatically using Java. The excel output files may contain ~200,000 rows which I plan to split over n

9条回答
  •  天涯浪人
    2020-12-24 15:14

    Is this memory issue happen when you insert data into cell, or when you perform data computation/generation?

    If you are going to load files into an excel that consist of predefined static template format, then better to save a template and reuse multiple time. Normally template cases happen when you are going to generate daily sales report or etc...

    Else, every time you need to create new row, border, column etc from scratch.

    So far, Apache POI is the only choice I found.

    "Clearly, writing ~20k rows(with some 10-20 columns in each row) gives me the dreaded "java.lang.OutOfMemoryError: Java heap space"."

    "Enterprise IT"

    What YOU CAN DO is- perform batch data insertion. Create a queuetask table, everytime after generate 1 page, rest for seconds, then continue second portion. If you are worry about the dynamic data changes during your queue task, you can first get the primary key into the excel (by hiding and lock the column from user view). First run will be insert primary key, then second queue run onwards will read out from notepad and do the task portion by portion.

提交回复
热议问题