<path id="scratchpad.classpath">
<path refid="main.classpath"/>
<pathelement location="${main.output.dir}"/>
+ <pathelement location="${scratchpad.output.dir}"/>
</path>
<path id="contrib.classpath">
<path id="test.ooxml.classpath">
<path refid="ooxml.classpath"/>
+ <path refid="scratchpad.classpath"/>
<pathelement location="${ooxml.output.dir}"/>
<pathelement location="${ooxml.output.test.dir}"/>
<pathelement location="${main.output.test.dir}"/> <!-- ooxml tests use some utilities from main tests -->
</javac>
</target>
- <target name="test" depends="test-main,test-scratchpad,test-contrib"
+ <target name="test" depends="test-main,test-scratchpad,test-contrib,test-ooxml"
description="Tests main, contrib and scratchpad"/>
<target name="-test-main-check">
<exclude name="**/All*Tests.java"/>
<exclude name="**/TestUnfixedBugs.java"/>
<exclude name="**/TestcaseRecordInputStream.java"/>
+ <exclude name="**/TestRawDataBlock.java"/>
+ <exclude name="**/TestRawDataBlockList.java"/>
</fileset>
</batchtest>
</junit>
<fileset dir="${ooxml.src.test}">
<include name="**/Test*.java"/>
<exclude name="**/All*Tests.java"/>
+ <exclude name="**/TestExtractorFactory.java"/>
</fileset>
</batchtest>
</junit>
<!-- Abort the build if JUnit is missing. -->
<target name="fail-unless-junit-is-available" depends="init">
<condition property="isAvailable.junit">
- <available classname="junit.framework.TestCase"/>
+ <available file="${junit.jar1.dir}"/>
</condition>
<antcall target="fail-junit"/>
</target>
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheetViews;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STPane;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.STPaneState;
public class XSSFSheet implements Sheet {
}
public void removeMergedRegion(int index) {
- // TODO Auto-generated method stub
-
+ CTMergeCell[] mergeCellsArray = new CTMergeCell[getMergedCells().sizeOfMergeCellArray() - 1];
+ for (int i = 0 ; i < getMergedCells().sizeOfMergeCellArray() ; i++) {
+ if (i < index) {
+ mergeCellsArray[i] = getMergedCells().getMergeCellArray(i);
+ }
+ else if (i > index) {
+ mergeCellsArray[i - 1] = getMergedCells().getMergeCellArray(i);
+ }
+ }
+ getMergedCells().setMergeCellArray(mergeCellsArray);
}
public void removeRow(Row row) {
assertEquals(1, sheet.getNumMergedRegions());
}
+ public void testRemoveMergedRegion() {
+ Workbook workbook = new XSSFWorkbook();
+ CTSheet ctSheet = CTSheet.Factory.newInstance();
+ CTWorksheet ctWorksheet = CTWorksheet.Factory.newInstance();
+ XSSFSheet sheet = new XSSFSheet(ctSheet, ctWorksheet, (XSSFWorkbook) workbook);
+ Region region_1 = new Region("A1:B2");
+ Region region_2 = new Region("C3:D4");
+ Region region_3 = new Region("E5:F6");
+ sheet.addMergedRegion(region_1);
+ sheet.addMergedRegion(region_2);
+ sheet.addMergedRegion(region_3);
+ assertEquals("C3:D4", ctWorksheet.getMergeCells().getMergeCellArray(1).getRef());
+ assertEquals(3, sheet.getNumMergedRegions());
+ sheet.removeMergedRegion(1);
+ assertEquals("E5:F6", ctWorksheet.getMergeCells().getMergeCellArray(1).getRef());
+ assertEquals(2, sheet.getNumMergedRegions());
+ sheet.removeMergedRegion(1);
+ sheet.removeMergedRegion(0);
+ assertEquals(0, sheet.getNumMergedRegions());
+ }
+
private XSSFSheet createSheet(XSSFWorkbook workbook, String name) {
XSSFSheet sheet = (XSSFSheet) workbook.createSheet(name);