mirror of https://github.com/apache/poi.git
whitespace (tabs to spaces, 3-space to 4-space)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1747879 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0e0afb3c72
commit
460540ded2
|
@ -223,7 +223,7 @@ public final class TestXSSFFormulaEvaluation extends BaseTestFormulaEvaluator {
|
||||||
assertEquals("In another workbook", cXSLX_nw_cell.getStringCellValue());
|
assertEquals("In another workbook", cXSLX_nw_cell.getStringCellValue());
|
||||||
*/
|
*/
|
||||||
} finally {
|
} finally {
|
||||||
alt.close();
|
alt.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
wb.close();
|
wb.close();
|
||||||
|
@ -361,53 +361,53 @@ public final class TestXSSFFormulaEvaluation extends BaseTestFormulaEvaluator {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMultisheetFormulaEval() throws IOException {
|
public void testMultisheetFormulaEval() throws IOException {
|
||||||
XSSFWorkbook wb = new XSSFWorkbook();
|
XSSFWorkbook wb = new XSSFWorkbook();
|
||||||
try {
|
try {
|
||||||
XSSFSheet sheet1 = wb.createSheet("Sheet1");
|
XSSFSheet sheet1 = wb.createSheet("Sheet1");
|
||||||
XSSFSheet sheet2 = wb.createSheet("Sheet2");
|
XSSFSheet sheet2 = wb.createSheet("Sheet2");
|
||||||
XSSFSheet sheet3 = wb.createSheet("Sheet3");
|
XSSFSheet sheet3 = wb.createSheet("Sheet3");
|
||||||
|
|
||||||
// sheet1 A1
|
// sheet1 A1
|
||||||
XSSFCell cell = sheet1.createRow(0).createCell(0);
|
XSSFCell cell = sheet1.createRow(0).createCell(0);
|
||||||
cell.setCellType(Cell.CELL_TYPE_NUMERIC);
|
cell.setCellType(Cell.CELL_TYPE_NUMERIC);
|
||||||
cell.setCellValue(1.0);
|
cell.setCellValue(1.0);
|
||||||
|
|
||||||
// sheet2 A1
|
// sheet2 A1
|
||||||
cell = sheet2.createRow(0).createCell(0);
|
cell = sheet2.createRow(0).createCell(0);
|
||||||
cell.setCellType(Cell.CELL_TYPE_NUMERIC);
|
cell.setCellType(Cell.CELL_TYPE_NUMERIC);
|
||||||
cell.setCellValue(1.0);
|
cell.setCellValue(1.0);
|
||||||
|
|
||||||
// sheet2 B1
|
// sheet2 B1
|
||||||
cell = sheet2.getRow(0).createCell(1);
|
cell = sheet2.getRow(0).createCell(1);
|
||||||
cell.setCellType(Cell.CELL_TYPE_NUMERIC);
|
cell.setCellType(Cell.CELL_TYPE_NUMERIC);
|
||||||
cell.setCellValue(1.0);
|
cell.setCellValue(1.0);
|
||||||
|
|
||||||
// sheet3 A1
|
// sheet3 A1
|
||||||
cell = sheet3.createRow(0).createCell(0);
|
cell = sheet3.createRow(0).createCell(0);
|
||||||
cell.setCellType(Cell.CELL_TYPE_NUMERIC);
|
cell.setCellType(Cell.CELL_TYPE_NUMERIC);
|
||||||
cell.setCellValue(1.0);
|
cell.setCellValue(1.0);
|
||||||
|
|
||||||
// sheet1 A2 formulae
|
// sheet1 A2 formulae
|
||||||
cell = sheet1.createRow(1).createCell(0);
|
cell = sheet1.createRow(1).createCell(0);
|
||||||
cell.setCellType(Cell.CELL_TYPE_FORMULA);
|
cell.setCellType(Cell.CELL_TYPE_FORMULA);
|
||||||
cell.setCellFormula("SUM(Sheet1:Sheet3!A1)");
|
cell.setCellFormula("SUM(Sheet1:Sheet3!A1)");
|
||||||
|
|
||||||
// sheet1 A3 formulae
|
// sheet1 A3 formulae
|
||||||
cell = sheet1.createRow(2).createCell(0);
|
cell = sheet1.createRow(2).createCell(0);
|
||||||
cell.setCellType(Cell.CELL_TYPE_FORMULA);
|
cell.setCellType(Cell.CELL_TYPE_FORMULA);
|
||||||
cell.setCellFormula("SUM(Sheet1:Sheet3!A1:B1)");
|
cell.setCellFormula("SUM(Sheet1:Sheet3!A1:B1)");
|
||||||
|
|
||||||
wb.getCreationHelper().createFormulaEvaluator().evaluateAll();
|
wb.getCreationHelper().createFormulaEvaluator().evaluateAll();
|
||||||
|
|
||||||
cell = sheet1.getRow(1).getCell(0);
|
cell = sheet1.getRow(1).getCell(0);
|
||||||
assertEquals(3.0, cell.getNumericCellValue(), 0);
|
assertEquals(3.0, cell.getNumericCellValue(), 0);
|
||||||
|
|
||||||
cell = sheet1.getRow(2).getCell(0);
|
cell = sheet1.getRow(2).getCell(0);
|
||||||
assertEquals(4.0, cell.getNumericCellValue(), 0);
|
assertEquals(4.0, cell.getNumericCellValue(), 0);
|
||||||
} finally {
|
} finally {
|
||||||
wb.close();
|
wb.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBug55843() throws IOException {
|
public void testBug55843() throws IOException {
|
||||||
|
@ -627,27 +627,27 @@ public final class TestXSSFFormulaEvaluation extends BaseTestFormulaEvaluator {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param row 0-based
|
* @param row 0-based
|
||||||
* @param column 0-based
|
* @param column 0-based
|
||||||
*/
|
*/
|
||||||
private void setCellFormula(Sheet sheet, int row, int column, String formula) {
|
private void setCellFormula(Sheet sheet, int row, int column, String formula) {
|
||||||
Row r = sheet.getRow(row);
|
Row r = sheet.getRow(row);
|
||||||
if (r == null) {
|
if (r == null) {
|
||||||
r = sheet.createRow(row);
|
r = sheet.createRow(row);
|
||||||
}
|
}
|
||||||
Cell cell = r.getCell(column);
|
Cell cell = r.getCell(column);
|
||||||
if (cell == null) {
|
if (cell == null) {
|
||||||
cell = r.createCell(column);
|
cell = r.createCell(column);
|
||||||
}
|
}
|
||||||
cell.setCellType(XSSFCell.CELL_TYPE_FORMULA);
|
cell.setCellType(XSSFCell.CELL_TYPE_FORMULA);
|
||||||
cell.setCellFormula(formula);
|
cell.setCellFormula(formula);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param rowNo 0-based
|
* @param rowNo 0-based
|
||||||
* @param column 0-based
|
* @param column 0-based
|
||||||
*/
|
*/
|
||||||
private Cell getCell(Sheet sheet, int rowNo, int column) {
|
private Cell getCell(Sheet sheet, int rowNo, int column) {
|
||||||
return sheet.getRow(rowNo).getCell(column);
|
return sheet.getRow(rowNo).getCell(column);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue