尝试使用事件API.有关详细信息,请参阅POI文档中的Event API (HSSF only)和XSSF and SAX (Event API).该页面的几个引用:
HSSF:
The event API is newer than the User API. It is intended for intermediate developers who are willing to learn a little bit of the low level API structures. Its relatively simple to use, but requires a basic understanding of the parts of an Excel file (or willingness to learn). The advantage provided is that you can read an XLS with a relatively small memory footprint.
XSSF:
If memory footprint is an issue, then for XSSF, you can get at the underlying XML data, and process it yourself. This is intended for intermediate developers who are willing to learn a little bit of low level structure of .xlsx files, and who are happy processing XML in java. Its relatively simple to use, but requires a basic understanding of the file structure. The advantage provided is that you can read a XLSX file with a relatively small memory footprint.
对于输出,在博客文章Streaming xlsx files中描述了一种可能的方法.(基本上,使用XSSF生成容器XML文件,然后将实际内容作为纯文本流式传输到xlsx zip存档的相应xml部分.)