Add reproducer for bug 56655
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1650069 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c15f7bc929
commit
f912ecac92
@ -17,6 +17,8 @@
|
|||||||
|
|
||||||
package org.apache.poi.xssf.usermodel;
|
package org.apache.poi.xssf.usermodel;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
@ -29,6 +31,7 @@ import org.apache.poi.hssf.HSSFTestDataSamples;
|
|||||||
import org.apache.poi.ss.usermodel.Cell;
|
import org.apache.poi.ss.usermodel.Cell;
|
||||||
import org.apache.poi.ss.usermodel.DataFormatter;
|
import org.apache.poi.ss.usermodel.DataFormatter;
|
||||||
import org.apache.poi.ss.usermodel.DateUtil;
|
import org.apache.poi.ss.usermodel.DateUtil;
|
||||||
|
import org.apache.poi.ss.usermodel.FormulaError;
|
||||||
import org.apache.poi.ss.usermodel.RichTextString;
|
import org.apache.poi.ss.usermodel.RichTextString;
|
||||||
import org.apache.poi.ss.usermodel.Row;
|
import org.apache.poi.ss.usermodel.Row;
|
||||||
import org.apache.poi.ss.usermodel.Sheet;
|
import org.apache.poi.ss.usermodel.Sheet;
|
||||||
@ -240,4 +243,66 @@ public final class TestUnfixedBugs extends TestCase {
|
|||||||
assertEquals(2, strBack.getIndexOfFormattingRun(1));
|
assertEquals(2, strBack.getIndexOfFormattingRun(1));
|
||||||
assertEquals(4, strBack.getIndexOfFormattingRun(2));
|
assertEquals(4, strBack.getIndexOfFormattingRun(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testBug56655() {
|
||||||
|
XSSFWorkbook wb = new XSSFWorkbook();
|
||||||
|
Sheet sheet = wb.createSheet();
|
||||||
|
|
||||||
|
setCellFormula(sheet, 0, 0, "#VALUE!");
|
||||||
|
setCellFormula(sheet, 0, 1, "SUMIFS(A:A,A:A,#VALUE!)");
|
||||||
|
|
||||||
|
XSSFFormulaEvaluator.evaluateAllFormulaCells(wb);
|
||||||
|
|
||||||
|
assertEquals(XSSFCell.CELL_TYPE_ERROR, getCell(sheet, 0,0).getCachedFormulaResultType());
|
||||||
|
assertEquals(FormulaError.VALUE.getCode(), getCell(sheet, 0,0).getErrorCellValue());
|
||||||
|
assertEquals(XSSFCell.CELL_TYPE_ERROR, getCell(sheet, 0,1).getCachedFormulaResultType());
|
||||||
|
assertEquals(FormulaError.VALUE.getCode(), getCell(sheet, 0,1).getErrorCellValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testBug56655a() {
|
||||||
|
XSSFWorkbook wb = new XSSFWorkbook();
|
||||||
|
Sheet sheet = wb.createSheet();
|
||||||
|
|
||||||
|
setCellFormula(sheet, 0, 0, "B1*C1");
|
||||||
|
sheet.getRow(0).createCell(1).setCellValue("A");
|
||||||
|
setCellFormula(sheet, 1, 0, "B1*C1");
|
||||||
|
sheet.getRow(1).createCell(1).setCellValue("A");
|
||||||
|
setCellFormula(sheet, 0, 3, "SUMIFS(A:A,A:A,A2)");
|
||||||
|
|
||||||
|
XSSFFormulaEvaluator.evaluateAllFormulaCells(wb);
|
||||||
|
|
||||||
|
assertEquals(XSSFCell.CELL_TYPE_ERROR, getCell(sheet, 0, 0).getCachedFormulaResultType());
|
||||||
|
assertEquals(FormulaError.VALUE.getCode(), getCell(sheet, 0, 0).getErrorCellValue());
|
||||||
|
assertEquals(XSSFCell.CELL_TYPE_ERROR, getCell(sheet, 1, 0).getCachedFormulaResultType());
|
||||||
|
assertEquals(FormulaError.VALUE.getCode(), getCell(sheet, 1, 0).getErrorCellValue());
|
||||||
|
assertEquals(XSSFCell.CELL_TYPE_ERROR, getCell(sheet, 0, 3).getCachedFormulaResultType());
|
||||||
|
assertEquals(FormulaError.VALUE.getCode(), getCell(sheet, 0, 3).getErrorCellValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param row 0-based
|
||||||
|
* @param column 0-based
|
||||||
|
*/
|
||||||
|
void setCellFormula(Sheet sheet, int row, int column, String formula) {
|
||||||
|
Row r = sheet.getRow(row);
|
||||||
|
if (r == null) {
|
||||||
|
r = sheet.createRow(row);
|
||||||
|
}
|
||||||
|
Cell cell = r.getCell(column);
|
||||||
|
if (cell == null) {
|
||||||
|
cell = r.createCell(column);
|
||||||
|
}
|
||||||
|
cell.setCellType(XSSFCell.CELL_TYPE_FORMULA);
|
||||||
|
cell.setCellFormula(formula);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param rowNo 0-based
|
||||||
|
* @param column 0-based
|
||||||
|
*/
|
||||||
|
Cell getCell(Sheet sheet, int rowNo, int column) {
|
||||||
|
return sheet.getRow(rowNo).getCell(column);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user