avoid corruption of XSSFWorkbook after removing all merged cells from sheet, see Bugzilla 49895

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@996148 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yegor Kozlov 2010-09-11 13:48:00 +00:00
parent 442579c326
commit 1f6833c72d
3 changed files with 8 additions and 1 deletions

View File

@ -34,6 +34,7 @@
<changes> <changes>
<release version="3.7-beta3" date="2010-??-??"> <release version="3.7-beta3" date="2010-??-??">
<action dev="poi-developers" type="fix">49895 - avoid corruption of XSSFWorkbook after removing all merged cells from sheet</action>
<action dev="poi-developers" type="fix">49907 - fixed inconsistent behaviour between HSSF and XSSF when creating consecutive names</action> <action dev="poi-developers" type="fix">49907 - fixed inconsistent behaviour between HSSF and XSSF when creating consecutive names</action>
<action dev="poi-developers" type="add">Add getMimeType() method to HWPF Picture, alongside existing file extension</action> <action dev="poi-developers" type="add">Add getMimeType() method to HWPF Picture, alongside existing file extension</action>
<action dev="poi-developers" type="add">Add code for reading Ole10Native data</action> <action dev="poi-developers" type="add">Add code for reading Ole10Native data</action>

View File

@ -1350,7 +1350,11 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
mergeCellsArray[i - 1] = ctMergeCells.getMergeCellArray(i); mergeCellsArray[i - 1] = ctMergeCells.getMergeCellArray(i);
} }
} }
ctMergeCells.setMergeCellArray(mergeCellsArray); if(mergeCellsArray.length > 0){
ctMergeCells.setMergeCellArray(mergeCellsArray);
} else{
worksheet.unsetMergeCells();
}
} }
/** /**

View File

@ -253,6 +253,8 @@ public final class TestXSSFSheet extends BaseTestSheet {
sheet.removeMergedRegion(1); sheet.removeMergedRegion(1);
sheet.removeMergedRegion(0); sheet.removeMergedRegion(0);
assertEquals(0, sheet.getNumMergedRegions()); assertEquals(0, sheet.getNumMergedRegions());
assertNull(" CTMergeCells should be deleted after removing the last merged " +
"region on the sheet.", sheet.getCTWorksheet().getMergeCells());
} }
public void testSetDefaultColumnStyle() { public void testSetDefaultColumnStyle() {