Add a test to show that the behaviour around bug #30635 is exactly as you would expect, and the bug report is invalid
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@675793 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
882d25e9e9
commit
b45b8f99f8
@ -1272,4 +1272,53 @@ public final class TestBugs extends TestCase {
|
|||||||
assertEquals("{=sin(B1:B9){9,1)[1][0]", nc2.getCellFormula());
|
assertEquals("{=sin(B1:B9){9,1)[1][0]", nc2.getCellFormula());
|
||||||
assertEquals("{=sin(B1:B9){9,1)[2][0]", nc3.getCellFormula());
|
assertEquals("{=sin(B1:B9){9,1)[2][0]", nc3.getCellFormula());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* People are all getting confused about the last
|
||||||
|
* row and cell number
|
||||||
|
*/
|
||||||
|
public void test30635() throws Exception {
|
||||||
|
HSSFWorkbook wb = new HSSFWorkbook();
|
||||||
|
HSSFSheet s = wb.createSheet();
|
||||||
|
|
||||||
|
// No rows, everything is 0
|
||||||
|
assertEquals(0, s.getFirstRowNum());
|
||||||
|
assertEquals(0, s.getLastRowNum());
|
||||||
|
assertEquals(0, s.getPhysicalNumberOfRows());
|
||||||
|
|
||||||
|
// One row, most things are 0, physical is 1
|
||||||
|
s.createRow(0);
|
||||||
|
assertEquals(0, s.getFirstRowNum());
|
||||||
|
assertEquals(0, s.getLastRowNum());
|
||||||
|
assertEquals(1, s.getPhysicalNumberOfRows());
|
||||||
|
|
||||||
|
// And another, things change
|
||||||
|
s.createRow(4);
|
||||||
|
assertEquals(0, s.getFirstRowNum());
|
||||||
|
assertEquals(4, s.getLastRowNum());
|
||||||
|
assertEquals(2, s.getPhysicalNumberOfRows());
|
||||||
|
|
||||||
|
|
||||||
|
// Now start on cells
|
||||||
|
HSSFRow r = s.getRow(0);
|
||||||
|
assertEquals(-1, r.getFirstCellNum());
|
||||||
|
assertEquals(-1, r.getLastCellNum());
|
||||||
|
assertEquals(0, r.getPhysicalNumberOfCells());
|
||||||
|
|
||||||
|
// Add a cell, things move off -1
|
||||||
|
r.createCell((short)0);
|
||||||
|
assertEquals(0, r.getFirstCellNum());
|
||||||
|
assertEquals(1, r.getLastCellNum()); // last cell # + 1
|
||||||
|
assertEquals(1, r.getPhysicalNumberOfCells());
|
||||||
|
|
||||||
|
r.createCell((short)1);
|
||||||
|
assertEquals(0, r.getFirstCellNum());
|
||||||
|
assertEquals(2, r.getLastCellNum()); // last cell # + 1
|
||||||
|
assertEquals(2, r.getPhysicalNumberOfCells());
|
||||||
|
|
||||||
|
r.createCell((short)4);
|
||||||
|
assertEquals(0, r.getFirstCellNum());
|
||||||
|
assertEquals(5, r.getLastCellNum()); // last cell # + 1
|
||||||
|
assertEquals(3, r.getPhysicalNumberOfCells());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user