private int count;
@Override
- public boolean processMatch(ValueEval eval, String field) {
- if (field == null || eval instanceof NumericValueEval) {
+ public boolean processMatch(ValueEval eval, int fieldNumber) {
+ if (fieldNumber < 0 || eval instanceof NumericValueEval) {
count++;
}
return true;
private ValueEval result;
@Override
- public boolean processMatch(ValueEval eval, String field) {
+ public boolean processMatch(ValueEval eval, int fieldNumber) {
if(result == null) // First match, just set the value.
{
result = eval;
private ValueEval maximumValue;
@Override
- public boolean processMatch(ValueEval eval, String field) {
+ public boolean processMatch(ValueEval eval, int fieldNumber) {
if(eval instanceof NumericValueEval) {
if(maximumValue == null) { // First match, just set the value.
maximumValue = eval;
private ValueEval minimumValue;
@Override
- public boolean processMatch(ValueEval eval, String field) {
+ public boolean processMatch(ValueEval eval, int fieldNumber) {
if(eval instanceof NumericValueEval) {
if(minimumValue == null) { // First match, just set the value.
minimumValue = eval;
final IDStarAlgorithm algorithm = algoType.newInstance();
int fc = -1;
- String field = null;
try {
filterColumn = OperandResolver.getSingleValue(filterColumn, srcRowIndex, srcColumnIndex);
- fc = getColumnForName(filterColumn, db);
- if (filterColumn instanceof StringEval) {
- field = ((StringEval)filterColumn).getStringValue();
+ if (filterColumn instanceof NumericValueEval) {
+ //fc is zero based while Excel uses 1 based column numbering
+ fc = (int) Math.round(((NumericValueEval)filterColumn).getNumberValue()) - 1;
+ } else {
+ fc = getColumnForName(filterColumn, db);
}
if(fc == -1 && !algorithm.allowEmptyMatchField()) {
// column not found
if(matches) {
ValueEval currentValueEval = resolveReference(db, row, fc);
// Pass the match to the algorithm and conditionally abort the search.
- boolean shouldContinue = algorithm.processMatch(currentValueEval, field);
+ boolean shouldContinue = algorithm.processMatch(currentValueEval, fc);
if(! shouldContinue) {
break;
}
private double totalValue = 0;
@Override
- public boolean processMatch(ValueEval eval, String field) {
+ public boolean processMatch(ValueEval eval, int fieldNumber) {
if(eval instanceof NumericValueEval) {
double currentValue = ((NumericValueEval)eval).getNumberValue();
totalValue += currentValue;
/**
* Process a match that is found during a run through a database.
* @param eval ValueEval of the cell in the matching row. References will already be resolved.
- * @param field the field name (added in POI 5.2.3)
+ * @param fieldNumber the field number (added in POI 5.2.3)
* @return Whether we should continue iterating through the database.
*/
- boolean processMatch(ValueEval eval, String field);
+ boolean processMatch(ValueEval eval, int fieldNumber);
/**
* Return a result ValueEval that will be the result of the calculation.
assertDouble(fe, cell, "DCOUNT(A5:E11,,A1:A2)", 3);
assertDouble(fe, cell, "DCOUNT(A5:E11, \"Age\", A1:A2)", 2);
assertDouble(fe, cell, "DCOUNT(A5:E11, \"Age\", A1:F2)", 1);
+ assertDouble(fe, cell, "DCOUNT(A5:E11, 3, A1:F2)", 1);
}
}
HSSFCell cell = wb.getSheetAt(0).getRow(0).createCell(100);
assertError(fe, cell, "DGET(A5:E11, \"Yield\", A1:A3)", FormulaError.NUM);
assertDouble(fe, cell, "DGET(A5:E11, \"Yield\", A1:F3)", 10);
+ assertDouble(fe, cell, "DGET(A5:E11, 4, A1:F3)", 10);
}
}
HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
HSSFCell cell = wb.getSheetAt(0).getRow(0).createCell(100);
assertDouble(fe, cell, "DGET(A5:E11, \"Yield\", A1:F3)", 6);
+ assertDouble(fe, cell, "DGET(A5:E11, 4, A1:F3)", 6);
}
}