==================================================================== */
package org.apache.poi.xssf.usermodel;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-
+import java.io.IOException;
import java.util.AbstractMap;
import java.util.Map;
import org.apache.poi.ss.formula.EvaluationSheet;
import org.apache.poi.ss.usermodel.BaseTestXEvaluationSheet;
+import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.Sheet;
import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.*;
+
class TestXSSFEvaluationSheet extends BaseTestXEvaluationSheet {
@Test
- void test() throws Exception {
+ void testSheetEval() throws Exception {
XSSFWorkbook wb = new XSSFWorkbook();
XSSFSheet sheet = wb.createSheet("test");
XSSFRow row = sheet.createRow(0);
assertEquals(sheet, evalsheet.getXSSFSheet());
}
+ @Test
+ void testBug65675() throws IOException {
+ try (XSSFWorkbook workbook = new XSSFWorkbook()) {
+ XSSFFormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator();
+ evaluator.setIgnoreMissingWorkbooks(true);
+
+ XSSFSheet sheet = workbook.createSheet("sheet");
+ XSSFRow row = sheet.createRow(0);
+ XSSFCell cell = row.createCell(0, CellType.FORMULA);
+
+ try {
+ cell.setCellFormula("[some-workbook-that-does-not-yet-exist.xlsx]main!B:D");
+ //it might be better if this succeeded but just adding this regression test for now
+ fail("expected exception");
+ } catch (RuntimeException re) {
+ assertEquals("Book not linked for filename some-workbook-that-does-not-yet-exist.xlsx", re.getMessage());
+ }
+ }
+ }
+
@Override
protected Map.Entry<Sheet, EvaluationSheet> getInstance() {
XSSFSheet sheet = new XSSFWorkbook().createSheet();
* Whether to ignore missing references to external workbooks and
* use cached formula results in the main workbook instead.
* <p>
- * In some cases exetrnal workbooks referenced by formulas in the main workbook are not avaiable.
+ * In some cases external workbooks referenced by formulas in the main workbook are not available.
* With this method you can control how POI handles such missing references:
* <ul>
* <li>by default ignoreMissingWorkbooks=false and POI throws {@link WorkbookNotFoundException}
public abstract class RefPtgBase extends OperandPtg {
/**
- * YK: subclasses of RefPtgBase are used by the FormulaParser and FormulaEvaluator accross HSSF and XSSF.
- * The bit mask should accommodate the maximum number of avaiable columns, i.e. 0x3FFF.
+ * YK: subclasses of RefPtgBase are used by the FormulaParser and FormulaEvaluator across HSSF and XSSF.
+ * The bit mask should accommodate the maximum number of available columns, i.e. 0x3FFF.
*
* @see org.apache.poi.ss.SpreadsheetVersion
*/