How can I get merged regions (merged cells) of an excel sheet using the event API provided by Apache POI?
Using the "traditional" DOM-like parsing style there are methods called Sheet.getNumMergedRegions()
and Sheet.getMergedRegion(int)
. Unfortunately I need to handle huge Excel files where I get out of memory errors even with the highest Xmx-value I am allowed to use (in this project). So I'd like to use the event API, but wasn't able to find out how to get information about merged regions, which I need to know to "understand" the content correctly...
Using the example given here: http://poi.apache.org/spreadsheet/how-to.html#xssf_sax_api I get events for each single cell of a merged region (only the first of them contains any textual content though). So maybe, if there isn't a more direct way, it would help to know how those merged cells could be (safely) distinguished from other (empty) cells...