mirror of
https://github.com/apache/poi.git
synced 2026-02-27 20:40:08 +08:00
[bug-65675] add regression test
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1894884 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
458369a64d
commit
02f36cf4fd
@ -41,7 +41,7 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
/**
|
||||
* A monthly calendar created using Apache POI. Each month is on a separate sheet.
|
||||
* This is a version of org.apache.poi.ss.examples.CalendarDemo that demonstrates
|
||||
* some XSSF features not avaiable when using common HSSF-XSSF interfaces.
|
||||
* some XSSF features not available when using common HSSF-XSSF interfaces.
|
||||
*
|
||||
* <pre>
|
||||
* Usage:
|
||||
|
||||
@ -25,7 +25,7 @@ import org.apache.poi.ss.util.CellRangeAddress;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
|
||||
/**
|
||||
* Demonstrates various settings avaiable in the Page Setup dialog
|
||||
* Demonstrates various settings available in the Page Setup dialog
|
||||
*/
|
||||
public class WorkingWithPageSetup {
|
||||
|
||||
|
||||
@ -16,22 +16,22 @@
|
||||
==================================================================== */
|
||||
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);
|
||||
@ -61,6 +61,26 @@ class TestXSSFEvaluationSheet extends BaseTestXEvaluationSheet {
|
||||
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();
|
||||
|
||||
@ -926,7 +926,7 @@ public final class WorkbookEvaluator {
|
||||
* 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}
|
||||
|
||||
@ -33,8 +33,8 @@ import org.apache.poi.util.LittleEndianOutput;
|
||||
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
|
||||
*/
|
||||
|
||||
@ -46,4 +46,5 @@ public abstract class BaseTestXEvaluationSheet {
|
||||
underlyingSheet.removeRow(underlyingSheet.getRow(2));
|
||||
assertEquals(1, instance.getLastRowNum());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user