Bug 56345

Summary: Reject single-cell merged regions?
Product: POI Reporter: David North <dtn-asfbugs>
Component: SS CommonAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: enhancement    
Priority: P2    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Linux   

Description David North 2014-04-03 11:09:25 UTC
Summary: Reject single-cell merged regions?

At the moment, both the XSSF and HSSF implementations of Sheet.addMergedRegion allow merged regions to be added which are single-cell ranges.

Excel 2007 and up complain that the workbook is corrupted in the case of an .xlsx containing single-cell merged regions.

Would it be reasonable to throw an IllegalArgumentException from addMergedRegion if the range is a single cell?

If so, happy to supply a patch & tests.
Comment 1 Dominik Stadler 2015-03-14 14:34:58 UTC
Yes, I think this would be useful. Please provide such a patch/test if possible
Comment 2 Javen O'Neal 2016-02-17 22:48:24 UTC
Added to (S)XSSFSheet.addMergedRegion in r1727776

Remaining: fix HSSFSheet.addMergedRegion [1]

[1] https://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java?revision=1717903&view=markup#l660
Comment 3 Javen O'Neal 2016-02-18 01:35:05 UTC
Added HSSFSheet implementation and unit test in r1730991.
Comment 4 Javen O'Neal 2016-02-18 02:07:00 UTC
Updated site docs in r1730993