Bit more towards XSSF name support for #56737, will need some deeper changes though to fully implement
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1611830 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
611bcffb0c
commit
551573dd95
@ -103,16 +103,39 @@ public final class XSSFEvaluationWorkbook implements FormulaRenderingWorkbook, E
|
|||||||
}
|
}
|
||||||
|
|
||||||
public NameXPtg getNameXPtg(String name, int sheetRefIndex) {
|
public NameXPtg getNameXPtg(String name, int sheetRefIndex) {
|
||||||
|
// First, try to find it as a User Defined Function
|
||||||
IndexedUDFFinder udfFinder = (IndexedUDFFinder)getUDFFinder();
|
IndexedUDFFinder udfFinder = (IndexedUDFFinder)getUDFFinder();
|
||||||
FreeRefFunction func = udfFinder.findFunction(name);
|
FreeRefFunction func = udfFinder.findFunction(name);
|
||||||
if(func == null) return null;
|
if (func != null) {
|
||||||
else return new NameXPtg(0, udfFinder.getFunctionIndex(name));
|
return new NameXPtg(0, udfFinder.getFunctionIndex(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Otherwise, try it as a named range
|
||||||
|
XSSFName xname = _uBook.getName(name);
|
||||||
|
if (xname != null) {
|
||||||
|
int nameAt = _uBook.getNameIndex(name);
|
||||||
|
return new NameXPtg(xname.getSheetIndex(), nameAt);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String resolveNameXText(NameXPtg n) {
|
public String resolveNameXText(NameXPtg n) {
|
||||||
int idx = n.getNameIndex();
|
int idx = n.getNameIndex();
|
||||||
|
String name = null;
|
||||||
|
|
||||||
|
// First, try to find it as a User Defined Function
|
||||||
IndexedUDFFinder udfFinder = (IndexedUDFFinder)getUDFFinder();
|
IndexedUDFFinder udfFinder = (IndexedUDFFinder)getUDFFinder();
|
||||||
return udfFinder.getFunctionName(idx);
|
name = udfFinder.getFunctionName(idx);
|
||||||
|
if (name != null) return name;
|
||||||
|
|
||||||
|
// Otherwise, try it as a named range
|
||||||
|
XSSFName xname = _uBook.getNameAt(idx);
|
||||||
|
if (xname != null) {
|
||||||
|
name = xname.getNameName();
|
||||||
|
}
|
||||||
|
|
||||||
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public EvaluationSheet getSheet(int sheetIndex) {
|
public EvaluationSheet getSheet(int sheetIndex) {
|
||||||
|
@ -2678,10 +2678,5 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
|||||||
|
|
||||||
// Try to evaluate everything
|
// Try to evaluate everything
|
||||||
eval.evaluateAll();
|
eval.evaluateAll();
|
||||||
|
|
||||||
// Try to set the same kinds of formula elsewhere
|
|
||||||
Cell newF = s.getRow(0).createCell(10, Cell.CELL_TYPE_FORMULA);
|
|
||||||
// TODO Fix this
|
|
||||||
//newF.setCellFormula("Defines!NR_To_A1");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
BIN
test-data/spreadsheet/ref-56737.xlsx
Normal file
BIN
test-data/spreadsheet/ref-56737.xlsx
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user