Bug 55745: fix handling of tables in XSSF if there are comments as well, add testcase which was committed to the wrong tag
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1546458 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6618473e64
commit
5511c6dbcc
@ -1043,7 +1043,7 @@ public final class TestXSSFSheet extends BaseTestSheet {
|
|||||||
assertEquals("XSSFSheet#removeRow did not clear calcChain entries",
|
assertEquals("XSSFSheet#removeRow did not clear calcChain entries",
|
||||||
0, calcChain.getCTCalcChain().sizeOfCArray());
|
0, calcChain.getCTCalcChain().sizeOfCArray());
|
||||||
|
|
||||||
//calcChain should be gone
|
//calcChain should be gone
|
||||||
wb = XSSFTestDataSamples.writeOutAndReadBack(wb);
|
wb = XSSFTestDataSamples.writeOutAndReadBack(wb);
|
||||||
assertNull(wb.getCalculationChain());
|
assertNull(wb.getCalculationChain());
|
||||||
|
|
||||||
@ -1055,49 +1055,49 @@ public final class TestXSSFSheet extends BaseTestSheet {
|
|||||||
public void testTables() {
|
public void testTables() {
|
||||||
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("WithTable.xlsx");
|
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("WithTable.xlsx");
|
||||||
assertEquals(3, wb.getNumberOfSheets());
|
assertEquals(3, wb.getNumberOfSheets());
|
||||||
|
|
||||||
// Check the table sheet
|
// Check the table sheet
|
||||||
XSSFSheet s1 = wb.getSheetAt(0);
|
XSSFSheet s1 = wb.getSheetAt(0);
|
||||||
assertEquals("a", s1.getRow(0).getCell(0).getRichStringCellValue().toString());
|
assertEquals("a", s1.getRow(0).getCell(0).getRichStringCellValue().toString());
|
||||||
assertEquals(1.0, s1.getRow(1).getCell(0).getNumericCellValue());
|
assertEquals(1.0, s1.getRow(1).getCell(0).getNumericCellValue());
|
||||||
|
|
||||||
List<XSSFTable> tables = s1.getTables();
|
List<XSSFTable> tables = s1.getTables();
|
||||||
assertNotNull(tables);
|
assertNotNull(tables);
|
||||||
assertEquals(1, tables.size());
|
assertEquals(1, tables.size());
|
||||||
|
|
||||||
XSSFTable table = tables.get(0);
|
XSSFTable table = tables.get(0);
|
||||||
assertEquals("Tabella1", table.getName());
|
assertEquals("Tabella1", table.getName());
|
||||||
assertEquals("Tabella1", table.getDisplayName());
|
assertEquals("Tabella1", table.getDisplayName());
|
||||||
|
|
||||||
// And the others
|
// And the others
|
||||||
XSSFSheet s2 = wb.getSheetAt(1);
|
XSSFSheet s2 = wb.getSheetAt(1);
|
||||||
assertEquals(0, s2.getTables().size());
|
assertEquals(0, s2.getTables().size());
|
||||||
XSSFSheet s3 = wb.getSheetAt(2);
|
XSSFSheet s3 = wb.getSheetAt(2);
|
||||||
assertEquals(0, s3.getTables().size());
|
assertEquals(0, s3.getTables().size());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test to trigger OOXML-LITE generating to include org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheetCalcPr
|
* Test to trigger OOXML-LITE generating to include org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheetCalcPr
|
||||||
*/
|
*/
|
||||||
public void testSetForceFormulaRecalculation() {
|
public void testSetForceFormulaRecalculation() {
|
||||||
XSSFWorkbook workbook = new XSSFWorkbook();
|
XSSFWorkbook workbook = new XSSFWorkbook();
|
||||||
XSSFSheet sheet = workbook.createSheet("Sheet 1");
|
XSSFSheet sheet = workbook.createSheet("Sheet 1");
|
||||||
|
|
||||||
// Set
|
// Set
|
||||||
sheet.setForceFormulaRecalculation(true);
|
sheet.setForceFormulaRecalculation(true);
|
||||||
assertEquals(true, sheet.getForceFormulaRecalculation());
|
assertEquals(true, sheet.getForceFormulaRecalculation());
|
||||||
|
|
||||||
// calcMode="manual" is unset when forceFormulaRecalculation=true
|
// calcMode="manual" is unset when forceFormulaRecalculation=true
|
||||||
CTCalcPr calcPr = workbook.getCTWorkbook().addNewCalcPr();
|
CTCalcPr calcPr = workbook.getCTWorkbook().addNewCalcPr();
|
||||||
calcPr.setCalcMode(STCalcMode.MANUAL);
|
calcPr.setCalcMode(STCalcMode.MANUAL);
|
||||||
sheet.setForceFormulaRecalculation(true);
|
sheet.setForceFormulaRecalculation(true);
|
||||||
assertEquals(STCalcMode.AUTO, calcPr.getCalcMode());
|
assertEquals(STCalcMode.AUTO, calcPr.getCalcMode());
|
||||||
|
|
||||||
// Check
|
// Check
|
||||||
sheet.setForceFormulaRecalculation(false);
|
sheet.setForceFormulaRecalculation(false);
|
||||||
assertEquals(false, sheet.getForceFormulaRecalculation());
|
assertEquals(false, sheet.getForceFormulaRecalculation());
|
||||||
|
|
||||||
|
|
||||||
// Save, re-load, and re-check
|
// Save, re-load, and re-check
|
||||||
workbook = XSSFTestDataSamples.writeOutAndReadBack(workbook);
|
workbook = XSSFTestDataSamples.writeOutAndReadBack(workbook);
|
||||||
sheet = workbook.getSheet("Sheet 1");
|
sheet = workbook.getSheet("Sheet 1");
|
||||||
@ -1210,4 +1210,22 @@ public final class TestXSSFSheet extends BaseTestSheet {
|
|||||||
assertNotNull(sh);
|
assertNotNull(sh);
|
||||||
assertEquals(ROW_COUNT-1, sh.getLastRowNum());
|
assertEquals(ROW_COUNT-1, sh.getLastRowNum());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void test55745() throws Exception {
|
||||||
|
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("55745.xlsx");
|
||||||
|
XSSFSheet sheet = wb.getSheetAt(0);
|
||||||
|
List<XSSFTable> tables = sheet.getTables();
|
||||||
|
/*System.out.println(tables.size());
|
||||||
|
|
||||||
|
for(XSSFTable table : tables) {
|
||||||
|
System.out.println("XPath: " + table.getCommonXpath());
|
||||||
|
System.out.println("Name: " + table.getName());
|
||||||
|
System.out.println("Mapped Cols: " + table.getNumerOfMappedColumns());
|
||||||
|
System.out.println("Rowcount: " + table.getRowCount());
|
||||||
|
System.out.println("End Cell: " + table.getEndCellReference());
|
||||||
|
System.out.println("Start Cell: " + table.getStartCellReference());
|
||||||
|
}*/
|
||||||
|
assertEquals("Sheet should contain 8 tables", 8, tables.size());
|
||||||
|
assertNotNull("Sheet should contain a comments table", sheet.getCommentsTable(false));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user