Bug 123407 - Copy&Paste-Error in Date-Cells from XLSX to ODS
Summary: Copy&Paste-Error in Date-Cells from XLSX to ODS
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: dataLoss
Depends on:
Blocks: Paste-From-MSO
  Show dependency treegraph
 
Reported: 2019-02-12 15:07 UTC by amersdorfer
Modified: 2024-11-04 20:01 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
XLSX-File (48.69 KB, application/zip)
2019-02-12 15:08 UTC, amersdorfer
Details

Note You need to log in before you can comment on or make changes to this bug.
Description amersdorfer 2019-02-12 15:07:26 UTC
Description:
When copying cells with a date from a XLSX-File, that is saved in an "old" Excel format ("1904") to a new ODS-File via Copy&Paste, the date gets automatically transformed by 4 years and 1 day. Eg. 27.12.2018 changes to 26.12.2014 in new ODS. Correct: 27.12.2018 should not change.

In the XLSX document under Tools - Options - LibreOffice Calc - Calculate, the date is set automatically at "01.01.1904". I suppose because the XLSX is a spreadsheet "in a foreign format". A standard ODS is set at "30.12.1899", so copy & pasting should honor the difference.

Steps to Reproduce:
1. Copy cell with Date from XLSX-file (Strg-C)
2. Paste in empty ODS or new spreadsheet

Actual Results:
Date cell with content "22.1.2018" changes to "21.1.2014"

Expected Results:
Content of Date cell should not change after paste to ODS-spreadsheet


Reproducible: Always


User Profile Reset: No



Additional Info:
Clipboard contains "22.1.2018"
Comment 1 amersdorfer 2019-02-12 15:08:43 UTC
Created attachment 149226 [details]
XLSX-File
Comment 2 Roman Kuznetsov 2019-02-12 16:10:43 UTC
Confirm with file from attach in

Version: 6.1.4.2
Build ID: 1:6.1.4-0ubuntu0.18.10.1
CPU threads: 4; OS: Linux 4.18; UI render: default; VCL: gtk3_kde5; 
Locale: ru-RU (ru_RU.UTF-8); Calc: group threaded
Comment 3 Xisco Faulí 2019-02-13 11:57:00 UTC
Also reproduced in

Version: 5.2.0.0.alpha0+
Build ID: 3ca42d8d51174010d5e8a32b96e9b4c0b3730a53
Threads 4; Ver: 4.15; Render: default; 

LibreOffice 3.3.0 
OOO330m19 (Build:6)
tag libreoffice-3.3.0.4

@Eike, I thought you could be interested in this issue...
Comment 4 QA Administrators 2021-02-13 04:04:18 UTC Comment hidden (obsolete)
Comment 5 amersdorfer 2021-02-15 11:19:33 UTC
Bug is still present with current version:

Version: 7.1.0.3 (x64) / LibreOffice Community
Build ID: f6099ecf3d29644b5008cc8f48f42f4a40986e4c
CPU threads: 12; OS: Windows 10.0 Build 19042; UI render: Skia/Raster;
VCL: win
Locale: de-AT (de_AT); UI: de-DE
Calc: threaded
Comment 6 Eike Rathke 2021-02-15 12:27:19 UTC
Dates in Excel and Calc are just number of days since the document's null date, and then the number is formatted as date. Some Excel for Mac versions (or if explicitly set in options) used a null date of 1904-01-01 hence all dates are 4 years off if the numeric date value is pasted to a document with 1899-12-30 null date. This is not .xlsx specific.

There's not much we can do, other than if null dates differ for every cell copied check if it's a date(+time) formatted cell and if so add the null date difference. While that could work for plain date(+time) cells, it may introduce unwanted effects if such cells' values were used in another numeric context. Though I guess most spreadsheets don't use such features and DATEVALUE() also takes the null date into account, but still, fiddling with the numeric cell value is fragile and quirks hard to track for the user.

Btw, what does Excel do when copying dates between different null date documents?
Comment 7 amersdorfer 2021-02-15 13:12:44 UTC
I understand your point, but the problem I see is the zero feedback by Calc, leading to data-loss/-corruption without knowing - we had this problem in our company with such an Excel-File.

Copy&paste within (!) Libreoffice should at the very least point out possible data-corruption.

Follow-up to your question.
Tested copy&paste from above attachment with Online-Excel (office.com), as I do not have access to an installed Excel:

1. Opened file with Libreoffice.
2. Selected & copied multiple cells into clipboard.
3. Pasted cells in Online Excel.
4. Dates remained the same (2018), as should be expected.

So even copy&paste from Libreoffice to Excel Online works but from Libreoffice to Libreoffice does not.
Comment 8 Eike Rathke 2021-02-15 14:57:48 UTC
That's a completely different scenario though because copying from LibreOffice to Online Excel the online Excel probably chooses HTML (or whatever) clipboard format in which the internal number of days since null date cell content is not present but a date string instead, for example.

The only valid comparison is to create a new document in Excel and loading the 1904 document in Excel and then copying from that to the newly created document. It may even be you have to use the "real" Excel not the online Excel because it might be the online Excel copies through a different clipboard format anyway. To expose this quirk the chosen clipboard format has to be one that uses the application internal representation of days since null date.
Comment 9 QA Administrators 2023-02-16 03:25:49 UTC Comment hidden (obsolete)
Comment 10 amersdorfer 2023-02-22 13:09:02 UTC
I was able to test the scenario with a current version of Excel and it gave the same result: The date is converted without any further information, so the behavior is equally unsatisfactory. Have therefore marked the still existing misbehavior as "resolved worksforme", even if - from my point of view - Libreoffice could go a better way here by means of a feedback when inserting.

Version: 7.4.5.1 (x64) / LibreOffice Community
Build ID: 9c0871452b3918c1019dde9bfac75448afc4b57f
CPU threads: 4; OS: Windows 10.0 Build 19045; UI render: Skia/Raster; VCL: win
Locale: de-AT (de_AT); UI: de-DE
Calc: threaded
Comment 11 Xisco Faulí 2023-02-22 13:16:34 UTC
The original report is still reproducible in

Version: 7.6.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 14844d835cc5d6dfde499a0b1074aea5dcff4fc7
CPU threads: 8; OS: Linux 5.10; UI render: default; VCL: gtk3
Locale: en-US (es_ES.UTF-8); UI: en-US
Calc: threaded