When dealing with spreadsheets (tested Excel and LibreOfice) when a function is called with a missing parameter, they sometimes provide a default empty string parameter. I noticed this with the substitute function: SUBSTITUTE( text, old_text, new_text, [nth_appearance] ) In the spreadsheet I was using, the mandatory "new_text" parameter was not specified. Excel and LibreOffice both provided a default empty string. I think the POI behaviour to throw an exception is correct (althought the error message is not very usefull) but, if the goal is to be compatible with Excel, then the behviour should probably be changed. public static String coerceValueToString(ValueEval ve) { if (ve instanceof StringValueEval) { StringValueEval sve = (StringValueEval) ve; return sve.getStringValue(); } if (ve == BlankEval.instance) { return ""; } // Start of patch if (ve == MissingArgEval.instance) { return ""; } // End of patch throw new IllegalArgumentException("Unexpected eval class (" + ve.getClass().getName() + ")"); }
Created attachment 36536 [details] Fixed usage of cell reference in Quotient Function I work with cquezel. I checked out the trunk and edited Quotient.java to de-reference cell references in Quotient function. I also added a line in the QuotientFunctionTestCaseData.xls test file to test having a cell reference as a numerator and denominator.