package org.apache.poi.hssf.record.cf;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
import org.apache.poi.ss.util.CellRangeAddress;
if(cellRanges.length < 1) {
return cellRanges;
}
- List temp = mergeCellRanges(Arrays.asList(cellRanges));
+
+ List<CellRangeAddress> lst = new ArrayList<CellRangeAddress>();
+ for(CellRangeAddress cr : cellRanges) lst.add(cr);
+ List temp = mergeCellRanges(lst);
return toArray(temp);
}
private static List mergeCellRanges(List cellRangeList)
assertEquals(100, box9x9.getNumberOfCells());
assertEquals(121, box10to20c.getNumberOfCells());
}
+
+ public void testMergeCellRanges() {
+ CellRangeAddress cr1 = CellRangeAddress.valueOf("A1:B1");
+ CellRangeAddress cr2 = CellRangeAddress.valueOf("A2:B2");
+ CellRangeAddress[] cr3 = CellRangeUtil.mergeCellRanges(new CellRangeAddress[]{cr1, cr2});
+ assertEquals(1, cr3.length);
+ assertEquals("A1:B2", cr3[0].formatAsString());
+ }
}