Apache OpenOffice (AOO) Bugzilla – Issue 58749
com.sun.star.sheet.FormulaResult.ERROR does not match
Last modified: 2017-05-20 11:27:49 UTC
Please run following basic code: REM ***** BASIC ***** sub test_FormulaResult_ERROR oDoc = StarDesktop.loadComponentFromURL( "private:factory/scalc", "_blank", 0, Array() ) oCell = oDoc.getSheets.getByIndex(0).getCellByPosition(0,0) oCell.setFormula("=1/0") printResult oCell end sub sub printResult(oCell) lContentType = oCell.getType lResultType = oCell.FormulaResultType sFml = oCell.FormulaLocal if lContentType = com.sun.star.table.CellContentType.FORMULA then sResult = sFml &" returning " if lResultType = com.sun.star.sheet.FormulaResult.ERROR then sResult = sResult & "an error" else sResult = sResult & "NO error" endif elseif lContentType = com.sun.star.table.CellContentType.TEXT then sResult = "Text: "& oCell.getString elseif lContentType = com.sun.star.table.CellContentType.VALUE then sResult = "Number: "& oCell.getValue endif msgbox sResult end sub
Iforgot to mention: A constant error-value (generated with paste special) pretends to be a string-formula
jsc -> nn: it's one for you
You can query for errors using getError (from XCell). But FormulaResult contains the ERROR value, so FormulaResultType should be changed to return it for errors.
The documentation is wrong, FormulaResultType is of type CellContentType, an enum that doesn't contain an ERROR value. Changing this might break existing code. Since a workaround exists (getError), I'm changing this to LATER.
Reset assigne to the default "issues@openoffice.apache.org".