Bug 168584 - Excel's WEEKNUM is imported as ODF WEEKNUM, instead of WEEKNUM_EXCEL2003
Summary: Excel's WEEKNUM is imported as ODF WEEKNUM, instead of WEEKNUM_EXCEL2003
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
4.2.0.4 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: bibisected, filter:xlsx, regression
Depends on:
Blocks: Cell-Formula
  Show dependency treegraph
 
Reported: 2025-09-28 08:10 UTC by Mike Kaganski
Modified: 2025-10-09 19:13 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
An Excel 2016 generated WEEKNUM sample (9.14 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2025-09-28 08:10 UTC, Mike Kaganski
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Kaganski 2025-09-28 08:10:12 UTC
Created attachment 203001 [details]
An Excel 2016 generated WEEKNUM sample

Open the attached XLSX. It was created in Excel 2016; it is expected to show the data as in Excel (at least when using en-US locale, which was used in Excel when creating it).

In Calc, it imports as WEEKNUM; and that is the ODF WEEKNUM [1], which differs in behavior in the last days of the year, which may be the same actual week as the next year's Jan 1, but in Excel, these last days are numbered 53 - compare columns C and D, which are plain numbers demonstrating what I see in column B on my system.

There is WEEKNUM_EXCEL2003 [2], which is described as "for interoperability with legacy documents created with older versions of Microsoft Excel", and which calculates as expected (a separate issue is WEEKNUM_EXCEL2003 doesn't allow missing second argument). However, it seems that newer Excel versions still use that version, so the import should produce WEEKNUM_EXCEL2003 in the document.

Another related issue is that WEEKNUM_EXCEL2003 isn't stored to ODS, but that's for a different bug report.

[1] https://docs.oasis-open.org/office/OpenDocument/v1.4/OpenDocument-v1.4-part4-formula.html#WEEKNUM
[2] https://wiki.documentfoundation.org/Documentation/Calc_Functions/WEEKNUM_EXCEL2003
Comment 1 m_a_riosv 2025-09-28 09:10:27 UTC
Reproducible
Version: 26.2.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 18d4e906551a8729baaf99d34dbdc0598c9b1413
CPU threads: 16; OS: Windows 11 X86_64 (build 26100); UI render: Skia/Vulkan; VCL: win
Locale: es-ES (es_ES); UI: en-US
Calc: CL threaded


The reult of WEEKEND() change to be different as Excel, from:
Versión: 5.4.7.2
Id. de compilación: c838ef25c16710f8838b1faec480ebba495259d0
Subprocs. CPU: 16; SO: Windows 6.2; Repres. IU: predet.; 
Configuración regional: es-ES (es_ES); Calc: CL


The import fails from:
Version: 4.4.7.2
Build ID: f3153a8b245191196a4b6b9abd1d0da16eead600
Locale: es_ES

Latest version that works for import and result are like Excel.
Version 3.6.7.2 (Build ID: e183d5b)

Tested with versions that I have installed.
Comment 2 raal 2025-09-29 16:43:04 UTC
After this commit (repo bibisect-42max) the first formula is WEEKNUM_ADD, others formulas are WEEKNUM 60a03e47fa56a7a29204532b49d5e329988c3092 is the first bad commit
commit 60a03e47fa56a7a29204532b49d5e329988c3092
Author: Matthew Francis <mjay.francis@gmail.com>
Date:   Sat Sep 5 20:01:54 2015 +0800

    source-hash-e1c2403802af2f13075d612ea5ef0e91cf23c878
    
    commit e1c2403802af2f13075d612ea5ef0e91cf23c878
    Author:     Kohei Yoshida <kohei.yoshida@gmail.com>
    AuthorDate: Wed Aug 7 16:35:06 2013 -0400
    Commit:     Kohei Yoshida <kohei.yoshida@gmail.com>
    CommitDate: Mon Aug 12 19:46:26 2013 -0400
    
        Map shared formulas to Calc's formula groups on xlsx import.
    
        Change-Id: If8d11c5ee55afd8529070a699ca50284880ceb45

There is lot's of crashes in this repo, I'm unable to bibisect more.
Comment 3 Saburo 2025-10-03 09:49:49 UTC
All formula is WEEKNUM, but The formula in cell B3 and below returns an error.
Version: 4.2.0.0.alpha1+
Build ID: 7a3b8b1a5a753627c6518b9a5b8e2a041d4d6331

commit 7a3b8b1a5a753627c6518b9a5b8e2a041d4d6331
    Author:     Kohei Yoshida <kohei.yoshida@collabora.com>
    AuthorDate: Mon Nov 4 19:03:43 2013 -0500
    Commit:     Kohei Yoshida <kohei.yoshida@collabora.com>
    CommitDate: Wed Nov 6 20:40:20 2013 -0500
    
        Compile formulas using internal API directly...
    
        rather than via UNO API which does triple conversion per formula expression.