Bug 87973 - XLSX:vlookup formula changed in path to external csv file after saved and re-opened
Summary: XLSX:vlookup formula changed in path to external csv file after saved and re-...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
4.3.3.2 release
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Attila Szűcs
URL:
Whiteboard: target:7.2.0 target:7.1.0.0.beta2
Keywords:
: 126821 (view as bug list)
Depends on:
Blocks: Function-Vlookup
  Show dependency treegraph
 
Reported: 2015-01-02 16:51 UTC by kenw
Modified: 2020-12-22 13:10 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
the file that contains the changed formulae (5.58 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2015-01-02 16:51 UTC, kenw
Details
The referenced csv file. (42 bytes, text/csv)
2015-01-03 08:29 UTC, kenw
Details
Reproducer examples (48.24 KB, application/x-zip-compressed)
2020-10-06 14:45 UTC, NISZ LibreOffice Team
Details

Note You need to log in before you can comment on or make changes to this bug.
Description kenw 2015-01-02 16:51:17 UTC
Created attachment 111659 [details]
the file that contains the changed formulae

In "test2.xlsx", there are formulae fetching data from a csv file "data2.csv" located in a different folder.

After the file was saved and re-opened, the formulae changed to something like those reported in an already reported bug (https://bugs.freedesktop.org/show_bug.cgi?id=63992).

Then, I tried to correct the formulae by deleting the extra parts.  After the file was saved and re-opened again, the formulae changed to something like this:

VLOOKUP(A2,[3]data2!a$1:B$20,2,0)

That is, the path to the referenced file (data2.csv) has changed to [3].
Comment 1 raal 2015-01-02 18:51:02 UTC
Hello,
is it duplicate of bug 76047?
Comment 2 kenw 2015-01-03 04:04:04 UTC
I don't think they are the same.

Take a look at this screenshot: http://imgbox.com/Fz3agg6H

This is what I got after I saved the file and re-opened it. You can see that the path is something like 'file:///(path to this file)/(path to the referenced file) ...'

The correct path should be simply 'file:///home/kenneth/downloads/data2.csv'

Then, as I said in the report, I tried to correct the path by deleting the extra parts. I saved the file and re-opened it and now the formulae look like [3]data2.csv

as shown in this screenshot:

http://imgbox.com/1Y9jQ3xv
Comment 3 raal 2015-01-03 06:48:06 UTC
Your file is in xlsx format (test2.xlsx). Are you able to reproduce issue with .ods format (test2.ods)?
Please attach .csv, I'll try to reproduce this.
Comment 4 kenw 2015-01-03 08:29:37 UTC
Created attachment 111681 [details]
The referenced csv file.

the referenced csv file.
Comment 5 kenw 2015-01-03 08:30:17 UTC
Seems that the ods format works fine.

I now attach the csv file.
Comment 6 raal 2015-01-03 12:02:06 UTC
I can confirm with Version: 4.5.0.0.alpha0+
Build ID: 7f476fea47f06a7f8cc961dd4f6595a524346fa5
TinderBox: Linux-rpm_deb-x86_64@46-TDF, Branch:master, Time: 2014-12-27_23:36:28

steps  to reproduce:
 - save csv file to /tmp
 - create xlsx file  in /tmp/testBug
 - add formula to xlsx file
      =IF(B2=0;"";VLOOKUP(A2;'file:///tmp/data2.csv'#$data2.A1:B20;2;0))
 - save as xlsx, close , reopen

Actual results:
formula changed to
 =IF(B2=0;"";VLOOKUP(A2;'file:///tmp/testBug/data2.csv'#$data2.A$1:B$20;2;0))

Expected results:
formula unchanged
Comment 7 kenw 2015-01-03 16:38:23 UTC
raal,

What if you now in the re-opened file delete "testBug/" (without quotes, of course), save the file and re-open it again?

Does the formula change?
Comment 8 raal 2015-01-03 21:46:49 UTC
(In reply to kenw from comment #7)
> raal,
> 
> What if you now in the re-opened file delete "testBug/" (without quotes, of
> course), save the file and re-open it again?
> 
> Does the formula change?

formula will change 
  =IF(B2=0;"";VLOOKUP(A2;[2]data2!a$1:B$20;2;0))
Comment 9 QA Administrators 2016-01-17 20:05:02 UTC Comment hidden (obsolete)
Comment 10 QA Administrators 2017-03-06 14:35:25 UTC Comment hidden (obsolete)
Comment 11 QA Administrators 2019-12-03 14:28:33 UTC Comment hidden (obsolete)
Comment 12 NISZ LibreOffice Team 2020-10-06 14:45:24 UTC
I checked this problem and still happens in:

Version: 7.1.0.0.alpha0+ (x64)
Build ID: f266feaebea39668392e3a3830e20e4670344658
CPU threads: 4; OS: Windows 6.3 Build 9600; UI render: Skia/Raster; VCL: win
Locale: hu-HU (hu_HU); UI: hu-HU
Calc: CL

I'll attach a bunch of reproducer documents in a zip:

test2.ods: source file made in LO7.1alpha that contains a VLOOKUP function referencing XLSX and CSV files in the same directory (data3.csv and data3-copy.xlsx) and in a subdirectory (data2.csv and data2-copy.xlsx) as well.

test2.xlsx: the above ods saved as XLSX. The VLOOKUP does not work in this one for the referenced files in the same directory, but works for the ones in the subdirectory. 
Excel 2013 reports invalid contents in this one and removes the formula with references to the same directory.

test2-rel.ods: the above ods saved with Options - Load/Save - Save URLs relative to filesystem OFF.

test2-rel.xlsx: test2-rel.ods saved to XLSX with Options - Load/Save - Save URLs relative to filesystem OFF. In this one all VLOOKUP functions work both in Calc/Excel.
Comment 13 NISZ LibreOffice Team 2020-10-06 14:45:52 UTC
Created attachment 166129 [details]
Reproducer examples
Comment 14 Commit Notification 2020-12-03 13:01:23 UTC
Attila Szűcs committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/f85d860ccbebd99bc128218148e2992c9415f221

tdf#87973 XLSX export: fix lost file names in modified links

It will be available in 7.2.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 15 Commit Notification 2020-12-03 19:52:43 UTC
Attila Szűcs committed a patch related to this issue.
It has been pushed to "libreoffice-7-1":

https://git.libreoffice.org/core/commit/7050a83525a24f81b8c317716726e896210f314f

tdf#87973 XLSX export: fix lost file names in modified links

It will be available in 7.1.0.0.beta2.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 16 NISZ LibreOffice Team 2020-12-22 13:10:01 UTC
*** Bug 126821 has been marked as a duplicate of this bug. ***