Download it now!
Bug 70882 - FormulaResultType return VALUE for cells with formula result #DIV/0! or #NAME?
Summary: FormulaResultType return VALUE for cells with formula result #DIV/0! or #NAME?
Status: RESOLVED NOTABUG
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
3.5.0 Beta0
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Macro-UNOAPI
  Show dependency treegraph
 
Reported: 2013-10-26 05:52 UTC by mindaugas.rucys
Modified: 2020-03-20 07:19 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
spreadsheet with mentioned macro and formulas (8.66 KB, application/vnd.oasis.opendocument.spreadsheet)
2013-10-26 05:52 UTC, mindaugas.rucys
Details

Note You need to log in before you can comment on or make changes to this bug.
Description mindaugas.rucys 2013-10-26 05:52:18 UTC
Created attachment 88141 [details]
spreadsheet with mentioned macro and formulas

Formula in A1 "=0/0" -> result #DIV/0!
Formula in B1 "=nonexistingsheet!A0" -> result #NAME?
Formula in C1 "=sums(A2:A3)" -> result #NAME?

Basic macro:

Sub Main
	sheet = thiscomponent.sheets.getbyindex(0)
	msgbox sheet.getcellbyposition(0,0).formularesulttype
	msgbox sheet.getcellbyposition(1,0).formularesulttype
	msgbox sheet.getcellbyposition(2,0).formularesulttype
End Sub

All mesageboxes return 1 (VALUE) instead of 4 (ERROR)
Comment 1 Joel Madero 2013-11-09 00:56:01 UTC
Thank you for reporting this issue! I have been able to confirm the issue on:
Version 3.5.0.beta0
Platform: Ubuntu 13.04 x64
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 
As I've been able to confirm this problem on an earlier release I am changing the version number as version is the earliest version that we can confirm the bug, we use comments to say that the bug exists in newer versions as well.

NOTE: Noel - I have no clue what should be returned by formularesulttype and the documentation isn't terribly helpful - I tested with a number, a =1 and then with the document provided and it basically always shows 1. Documentation says it should return a long so, not sure if this is a bug or behaving as expected but I can confirm the behavior so marking as NEW

Marking as:

New (confirmed)
Normal
Medium

Keywords - 

Whiteboard Status -

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 
LibreOffice is powered by a team of volunteers, every bug is confirmed (triaged) by human beings who mostly give their time for free. We invite you to join our triaging by checking out this link:
https://wiki.documentfoundation.org/QA/BugTriage

There are also other ways to get involved including with marketing, UX, documentation, and of course developing -  http://www.libreoffice.org/get-help/mailing-lists/. 

Lastly, good bug reports help tremendously in making the process go smoother, please always provide reproducible steps (even if it seems easy) and attach any and all relevant material
Comment 2 QA Administrators 2015-04-19 03:22:19 UTC Comment hidden (obsolete)
Comment 3 Buovjaga 2015-06-18 13:48:38 UTC
(In reply to mindaugas.rucys from comment #0)
> Created attachment 88141 [details]
> spreadsheet with mentioned macro and formulas
> 
> Formula in A1 "=0/0" -> result #DIV/0!
> Formula in B1 "=nonexistingsheet!A0" -> result #NAME?
> Formula in C1 "=sums(A2:A3)" -> result #NAME?

Still same results.

Win 7 Pro 64-bit Version: 5.1.0.0.alpha1+
Build ID: 437210d58f32177ef1829d704f7f4d2f1bbfbfdd
TinderBox: Win-x86@39, Branch:master, Time: 2015-06-18_07:21:56
Locale: fi-FI (fi_FI)
Comment 4 QA Administrators 2016-09-20 10:10:26 UTC Comment hidden (obsolete)
Comment 5 Buovjaga 2019-08-11 11:15:46 UTC
Still confirmed

Arch Linux 64-bit
Version: 6.4.0.0.alpha0+
Build ID: 37fc9f51a8de11d40632e8cda17ccf1fa4b1f503
CPU threads: 8; OS: Linux 5.2; UI render: default; VCL: gtk3; 
Locale: fi-FI (fi_FI.UTF-8); UI-Language: en-US
Calc: threaded
Built on 6 August 2019
Comment 6 Andreas Heinisch 2019-08-29 12:24:51 UTC
In my case it returns 1, 0, 0:
https://api.libreoffice.org/docs/idl/ref/namespacecom_1_1sun_1_1star_1_1table.html#affea688ab9e00781fa35d8a790d10f0e

enum CellContentType - is used to determine the type of contents in a cell.

CellContentType_EMPTY = 0,
CellContentType_VALUE = 1,
CellContentType_TEXT = 2,
CellContentType_FORMULA = 3,
CellContentType_MAKE_FIXED_SIZE = SAL_MAX_ENUM

Maybe FormulaResult should used instead of CellContentType?

This property returns not com::sun::star::sheet::FormulaResult but instead com::sun::star::table::CellContentType. Use FormulaResult2 if the correct property is needed.

https://api.libreoffice.org/docs/idl/ref/namespacecom_1_1sun_1_1star_1_1sheet_1_1FormulaResult.html
Comment 7 Mike Kaganski 2020-03-20 07:19:35 UTC
This is not a bug.

As described in description of FormulaResultType attribute of SheetCell Service Reference [1], its return value is CellContentType (see comment 6), which lacks any ERROR value (and it's impossible to change the enumeration, because it's breaking the API and ABI); to obtain a com::sun::star::sheet::FormulaResult constant (having ERROR value), you need to use FormulaResultType2 attribute of the same service (which likely was introduced for that very reason).

Or you can use getError() of XCell Interface [2], like described in [3].

[1] https://api.libreoffice.org/docs/idl/ref/servicecom_1_1sun_1_1star_1_1sheet_1_1SheetCell.html#affda686bb18571c67c625c9adc1c85f9
[2] https://api.libreoffice.org/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1table_1_1XCell.html#a79278ec2dc4228f41254eef7e33729f0
[3] https://ask.libreoffice.org/en/question/83622/macro-how-to-get-a-cell-value-set-by-a-formula/