mirror of https://github.com/apache/poi.git
Bug 54524: Fix border case in FormulaShifter
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1517676 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d3bfcda99e
commit
8693b4f997
|
@ -85,6 +85,7 @@ public final class FormulaShifter {
|
|||
return new FormulaShifter(srcSheetIndex, dstSheetIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
|
||||
|
@ -322,7 +323,7 @@ public final class FormulaShifter {
|
|||
aptg.setFirstRow(destLastRowIndex+1);
|
||||
return aptg;
|
||||
}
|
||||
if (destFirstRowIndex < aLastRow && aLastRow <= destLastRowIndex) {
|
||||
if (destFirstRowIndex <= aLastRow && aLastRow < destLastRowIndex) {
|
||||
// dest rows overlap bottom of area
|
||||
// - truncate the bottom
|
||||
aptg.setLastRow(destFirstRowIndex-1);
|
||||
|
|
|
@ -17,8 +17,13 @@
|
|||
|
||||
package org.apache.poi.xssf.usermodel;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.poi.ss.usermodel.BaseTestSheetShiftRows;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.util.CellUtil;
|
||||
import org.apache.poi.xssf.XSSFITestDataProvider;
|
||||
import org.apache.poi.xssf.XSSFTestDataSamples;
|
||||
|
||||
/**
|
||||
* @author Yegor Kozlov
|
||||
|
@ -36,4 +41,17 @@ public final class TestXSSFSheetShiftRows extends BaseTestSheetShiftRows {
|
|||
public void testShiftWithComments() { // disabled test from superclass
|
||||
// TODO - support shifting of comments.
|
||||
}
|
||||
|
||||
public void testBug54524() throws IOException {
|
||||
XSSFWorkbook workbook = XSSFTestDataSamples.openSampleWorkbook("54524.xlsx");
|
||||
XSSFSheet sheet = workbook.getSheetAt(0);
|
||||
sheet.shiftRows(3, 5, -1);
|
||||
|
||||
Cell cell = CellUtil.getCell(sheet.getRow(1), 0);
|
||||
assertEquals(1.0, cell.getNumericCellValue());
|
||||
cell = CellUtil.getCell(sheet.getRow(2), 0);
|
||||
assertEquals("SUM(A2:A2)", cell.getCellFormula());
|
||||
cell = CellUtil.getCell(sheet.getRow(3), 0);
|
||||
assertEquals("X", cell.getStringCellValue());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
package org.apache.poi.ss.formula;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.poi.ss.formula.ptg.AreaErrPtg;
|
||||
import org.apache.poi.ss.formula.ptg.AreaPtg;
|
||||
import org.apache.poi.ss.formula.ptg.Ptg;
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue