Bug 44132 - FILESAVE XLSX XLS =ISEVEN() formula does not work when saving in .xls and .xlsx formats
Summary: FILESAVE XLSX XLS =ISEVEN() formula does not work when saving in .xls and .xl...
Status: CLOSED WONTFIX
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
3.3.4 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Calc-Function
  Show dependency treegraph
 
Reported: 2011-12-24 20:27 UTC by Gorka Navarrete
Modified: 2020-08-26 15:28 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments
ods format - All works fine (11.99 KB, application/vnd.oasis.opendocument.spreadsheet)
2011-12-24 20:27 UTC, Gorka Navarrete
Details
file saved in LO as .xls - #MACRO? error (9.50 KB, application/vnd.ms-excel)
2011-12-24 20:28 UTC, Gorka Navarrete
Details
saved in MS2010 as .xls - #ADDIN? error (7.50 KB, application/vnd.ms-excel)
2011-12-24 20:29 UTC, Gorka Navarrete
Details
saved in MS2010 as .xlsx - OK (5.52 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2011-12-24 20:29 UTC, Gorka Navarrete
Details
The example file saved & reopened with Calc as XLS/XLSX (101.73 KB, image/png)
2020-08-26 12:00 UTC, NISZ LibreOffice Team
Details
The example file saved with Calc as XLS/XLSX & opened in Excel (114.85 KB, image/png)
2020-08-26 12:01 UTC, NISZ LibreOffice Team
Details
The =IF(ISEVEN(E3)=1;1;0) in the function wizard of Calc / Excel (134.70 KB, image/png)
2020-08-26 12:02 UTC, NISZ LibreOffice Team
Details
The example file saved with Excel as XLS/XLSX and opened in Calc (119.78 KB, image/png)
2020-08-26 12:04 UTC, NISZ LibreOffice Team
Details
The example file saved with Excel as XLS (28.00 KB, application/vnd.ms-excel)
2020-08-26 12:05 UTC, NISZ LibreOffice Team
Details
The example file saved with Excel as XLSX (9.43 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2020-08-26 12:08 UTC, NISZ LibreOffice Team
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Gorka Navarrete 2011-12-24 20:27:25 UTC
Created attachment 54800 [details]
ods format - All works fine

If you open a new LibreOffice Calc file, fill E2 cell with a number and Use =ISEVEN(E2) formula, it gives the adequate response (TRUE if even number, FALSE otherwise).

(1)If you save the file in .ods format, everything works as expected.

(2) The problem starts if you save and close the document and reopen again. In this case, it gives a #MACRO? error.
	If you Edit cell (E2) and press INTRO, same error.
	If you Edit cell (E2), move cursor (Left or right arrow) and press INTRO, OK.

If you open the document in Spanish version of MS Excel 2007 or 2010, works fine. Converts formula to =ES.PAR(E2).
	(3)If you save the document in the Spanish version of MS Excel 2010 in .xls format and open it again in LibreOffice, it gives #ADDIN? error. Formula has changed to =ES.PAR(E2).
	(4)If you save the document in the Spanish version of MS Excel 2010 in .xlsx format and open it again in LibreOffice, it works OK. Formula has changed to =ISEVEN_ADD(E2).


Attaching 4 files:
(1)LibreofficeTest.ods - All works fine
(2)LibreofficeTestLinux.xls - saved in LO as .xls - #MACRO? error
(3)LibreofficeTest.xls - saved in MS2010 as .xls - #ADDIN? error
(4)LibreofficeTest.xlsx - saved in MS2010 as .xlsx - OK
Comment 1 Gorka Navarrete 2011-12-24 20:28:44 UTC
Created attachment 54801 [details]
file saved in LO as .xls - #MACRO? error
Comment 2 Gorka Navarrete 2011-12-24 20:29:32 UTC
Created attachment 54802 [details]
saved in MS2010 as .xls - #ADDIN? error
Comment 3 Gorka Navarrete 2011-12-24 20:29:53 UTC
Created attachment 54803 [details]
saved in MS2010 as .xlsx - OK
Comment 4 Regina Henschel 2011-12-29 13:05:47 UTC
For me the way LOdev3.5 beta2 => Excel 2010 works for file type xls and xlsx as well if you use ISEVEN
The way from Excel 2010 to LOdev3.5 beta uses for both file types ISEVEN_ADD in import. That is not good for a roundtrip with xlsx, because ISEVEN_ADD is not converted to ISEVEN on export. For xls roundtrip is works, but the exported function, which belongs to ISEVEN_ADD gives a converting warning in Excel.

Excel 2010 can handle ISEVEN for file type xls and for file type xlsx. Perhaps it is time to drop ISEVEN_ADD at least for file type xlsx?

I use LOdev3.5 beta2 on WinXP and German Excel 2010.

Gorka Navarrete: It is not clear to me, whether you use new documents when you save in MS2010 or save in LO, or whether you try a roundtrip. Please specify exactly the way creation => save => load => resave => reload
Comment 5 Gorka Navarrete 2011-12-30 01:30:30 UTC
Regina, I did a roundtrip. I created the documents in LO. In the process I describe in the bug report there is no more file creation that the original in LO. The rest comes from "Save as".
Comment 6 sasha.libreoffice 2012-05-03 02:31:03 UTC
reproduced in 3.3.4 and 3.5.3 on Fedora 64 bit and 3.5.2 on Windows XP 32 bit
ods from first attachment saved in xls using LO and then loaded by it again. As result, cells in first column contain error "Macro?"

changing version to 3.3.4 as most early reproducible
Comment 7 Thomas Arnhold 2014-06-28 02:07:25 UTC
I can confirm Regina's description: ISEVEN() is replaced by ISEVEN_ADD().

But there are no more macro errors with Libo 4.2.5.
Comment 8 QA Administrators 2015-07-18 17:42:36 UTC Comment hidden (obsolete)
Comment 9 QA Administrators 2016-09-20 10:17:49 UTC Comment hidden (obsolete)
Comment 10 NISZ LibreOffice Team 2020-08-26 11:59:31 UTC
Rechecking this:
* Saving the example attachment 54800 [details] as XLSX in current Calc 7.1alpha the exported function is ISEVEN, works the same on reload as the ODS.


* Saving the example attachment 54800 [details] as XLS in current Calc 7.1alpha the exported function is ISEVEN but on reload it's opened as ISEVEN_ADD, works the same as the ODS.

Opening these in Excel gives different result in case of the fifth line:
In Excel 13 the IF function gives a different result on IF(ISEVEN(E3)=1;1;0) and =IF(ISEVEN(E2)=1;1;0) probably only accidentally gives the same result as in Calc: 
IF can evaluate comparison with numbers in Calc as true/false while they seem always to be false inc Excel. 
ISEVEN(E3)=1 as condition of IF is really ISEVEN(2)=1 which makes the condition TRUE=1

I'm not sure if this is a bug or a feature, in any case it's not clearly documented at: 
https://help.libreoffice.org/7.1/en-US/text/scalc/01/04060105.html?DbPAR=CALC#bm_id3150141

When the ODS is saved in Excel 13 as XLSX and opened in Calc, it opens as ISEVEN and works the same as the ODS - but Excel cached the result of IF(ISEVEN(E3)=1;1;0) so a hard recalc is needed (unlike in case of LO-saved XLSX). All in all this can be considered good on our end.

When the ODS is saved in a Hungarian Excel 13 as XLS and opened in Calc, it opens as =IF(PÁROSE(E3)=1;1;0) with English locale Calc and as =HA(PÁROSE(E3)=1;1;0) with Hungarian locale Calc in the input line but the grid in both cases displays the #ADDIN? error.
This part is annoying, but should be an extremely rare case.
Comment 11 NISZ LibreOffice Team 2020-08-26 12:00:55 UTC
Created attachment 164712 [details]
The example file saved & reopened with Calc as XLS/XLSX
Comment 12 NISZ LibreOffice Team 2020-08-26 12:01:41 UTC
Created attachment 164713 [details]
The example file saved with Calc as XLS/XLSX & opened in Excel
Comment 13 NISZ LibreOffice Team 2020-08-26 12:02:46 UTC
Created attachment 164714 [details]
The =IF(ISEVEN(E3)=1;1;0) in the function wizard of Calc / Excel
Comment 14 NISZ LibreOffice Team 2020-08-26 12:04:13 UTC
Created attachment 164715 [details]
The example file saved with Excel as XLS/XLSX and opened in Calc
Comment 15 NISZ LibreOffice Team 2020-08-26 12:05:44 UTC
Created attachment 164716 [details]
The example file saved with Excel as XLS

This might be the most problematic in some extra rare cases.
Comment 16 NISZ LibreOffice Team 2020-08-26 12:08:56 UTC
Created attachment 164717 [details]
The example file saved with Excel as XLSX

Just for reference
Comment 17 NISZ LibreOffice Team 2020-08-26 12:10:09 UTC
@Eike could you advise on the IF situation? Is this seemingly different evaluation a bug or an underdocumented feature?
Comment 18 Eike Rathke 2020-08-26 15:28:44 UTC
This is nothing about the IF() function. It is ISEVEN() (and others, like ISODD, GCD, LCM, ...) that in older Excel versions exist only as Add-In functions, hence are stored differently in .xls BIFF and apparently when Excel writes that in an (older?) localized version it confuses the hell out of that and writes the localized name (in attachment 54802 [details] as ES.PAR in LBL - Internal Defined Name, or in attachment 164716 [details] as PÁROSE in EXTERNNAME - Externally Defined Name record, seems different Excel versions even do it differently) which of course Calc doesn't know. Nothing we can do about other than adding a pile of translations for the old Add-In functions just to satisfy a legacy document format.

Conclusion: do not use .xls BIFF to store roundtrip documents.

Additionally, older Excel versions don't do an automatic conversion from boolean to number (or vice versa), so an expression like
ISEVEN(E2)=1
is *always* FALSE because ISEVEN() returns boolean and boolean=number is never equal. Modern Excel versions handle that. Don't ask me for numbers when that started. For older versions you'll need to write
ISEVEN(E2)=TRUE()
or
N(ISEVEN(E2))=1
but in this case a simple
ISEVEN(E2)
would had been sufficient anyway.

The only case left then is
(2)LibreofficeTestLinux.xls - saved in LO as .xls - #MACRO? error
but that doesn't happen anymore (tried in LO7 and LO5.3), loading the .ods and saving as .xls and reloading calculates fine, even with the Add-In function ISEVEN_ADD() (only the automatic BOOLEAN format on A2 and A3 is lost if no number format was assigned).

ISEVEN_ADD() also isn't stored to .xlsx OOXML, stored is ISEVEN() instead, so we are good there.