Bug 56146 - coerceValueToString does not return an empty string when given a MissingArgEval parameter
Summary: coerceValueToString does not return an empty string when given a MissingArgEv...
Status: NEW
Alias: None
Product: POI
Classification: Unclassified
Component: SS Common (show other bugs)
Version: 3.9-FINAL
Hardware: PC All
: P2 minor (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2014-02-17 17:01 UTC by cquezel
Modified: 2019-04-19 12:43 UTC (History)
1 user (show)

Fixed usage of cell reference in Quotient Function (4.91 KB, patch)
2019-04-19 12:43 UTC, Ian Giguère
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description cquezel 2014-02-17 17:01:54 UTC
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() + ")");
Comment 1 Ian Giguère 2019-04-19 12:43:57 UTC
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.