Bug 142905 - LEFT() and empty space at the beginning in .xlsx
Summary: LEFT() and empty space at the beginning in .xlsx
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
7.1.3.2 release
Hardware: All Windows (All)
: medium normal
Assignee: Czeber László Ádám (NISZ)
URL:
Whiteboard: target:24.2.0 target:7.6.0.2
Keywords: filter:xlsx
Depends on:
Blocks: Calc-Function
  Show dependency treegraph
 
Reported: 2021-06-17 08:00 UTC by PremPa
Modified: 2023-07-26 09:03 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
First LEFT may refers to a blank cell (7.40 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2021-06-17 08:00 UTC, PremPa
Details

Note You need to log in before you can comment on or make changes to this bug.
Description PremPa 2021-06-17 08:00:12 UTC
Created attachment 172963 [details]
First LEFT may refers to a blank cell

If LEFT() formula inserts spaces at the beginning of the string (because the cell it refers to is blank) and is saved as .xlsx, when you reopne the file, the string ignores spaces until it is recalculated.

By copying and pasting before the recalculation the leading spaces are missing.

Saving in .ods the formula works correctly and the copy and paste works as expected.
Comment 1 Xisco Faulí 2021-06-17 08:20:01 UTC
Hello PremPa,
thanks for reporting this issue.
Could you please explain the steps to reproduce the issue using the attached file ?
Comment 2 PremPa 2021-06-17 13:57:39 UTC
(In reply to Xisco Faulí from comment #1)
> Hello PremPa,
> thanks for reporting this issue.
> Could you please explain the steps to reproduce the issue using the attached
> file ?

Sure.

If I open the attached file I see the cell R2 with no blank spaces at the beginnig.
Now if I press F9 the cell is recalculated and the first 5 spaces related to the formula LEFT(M3&"     ";5) appears

If I save in ods everything works correctly.

If you want to try in a new fil just type in A1

=LEFT(A2&"     ";5)&LEFT(B2&"     ";5)&LEFT(C2&"     ";5)

leave A2 empty, type something in B2 and in C2, save in xlsx and reopen: the first five spaces doesen't are there
Press F9 and they will appear.
Comment 3 m_a_riosv 2021-06-25 13:57:34 UTC
Repro
Version: 7.3.0.0.alpha0+ (x64) / LibreOffice Community
Build ID: 6805efdecb240fad8c82a5c1756a2a0e92f12b7d
CPU threads: 4; OS: Windows 10.0 Build 21390; UI render: Skia/Vulkan; VCL: win
Locale: es-ES (es_ES); UI: en-US Calc: threaded
Comment 4 Commit Notification 2023-07-25 13:50:25 UTC
Czeber László Ádám committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/7ec4c6df68233b73b1e257e013583ca49fc2ec9b

tdf#142905 XLSX import: don't trim leading spaces in formula cell

It will be available in 24.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 5 Commit Notification 2023-07-26 09:03:24 UTC
Czeber László Ádám committed a patch related to this issue.
It has been pushed to "libreoffice-7-6":

https://git.libreoffice.org/core/commit/15e8278144a7326e9587a665e9e1068562309295

tdf#142905 XLSX import: don't trim leading spaces in formula cell

It will be available in 7.6.0.2.

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.