FpSpread.OpenExcel fails when CurrentThread.CurrentCulture is en-CH

Posted by: ivan.dimitrov on 24 February 2023, 1:46 am EST

    • Post Options:
    • Link

    Posted 24 February 2023, 1:46 am EST - Updated 24 February 2023, 1:53 am EST

    Hi,

    When the CurrentCulture is English(Switzerland)[/code], en-CH, LCID=4096 the OpenExcel function fails to open the file, because internally throws CultureNotFound on constructing from LCID( new CultureInfo(4096)).

    An example in VB.NET:

    Dim spread = New FpSpread()
    System.Threading.Thread.CurrentThread.CurrentCulture = New CultureInfo("en-CH")
    Dim isOpen = spread.OpenExcel("file.xlsx")

    Here isOpen is false.

    If the CurrentCulture is en-us for example same file is properly open.

    Tried versions are v15 and v16

  • Posted 27 February 2023, 6:11 am EST

    Hi Ivan,

    Unfortunately, we could not replicate the issue on our end. We have attached a sample application showing our implementation. (See CultureIssue.zip)

    We request you update the sample application accordingly so that we replicate the issue on our end. This will help us analyze the issue in a better way.

    Thanks & Regards,

    Aastha

  • Posted 27 February 2023, 7:38 pm EST

    Hi Aastha,

    The project in which this happens is net 6 core(I’ve attached CultureInfoIssue.zip). Looks like the initialization from LCID for the CultureInfo is known issue in NET6: https://github.com/dotnet/runtime/issues/60296#issuecomment-942534495 with recommendation of using initialization through the name constructor.

    Also important point is that it happens when FpSpread is constructed with LegacyBehaviors different than NONE(LegacyBehaviors.All in the sample application).

  • Posted 1 March 2023, 6:47 am EST

    Hi Ivan,

    Unfortunately, we were unable to replicate the issue you reported on our end, and it appears to be specific to your machine. We suggest trying to run the same project without the FpSpread control and only include the following line of code on the same machine:

    System.Threading.Thread.CurrentThread.CurrentCulture = New CultureInfo("en-CH")

    Please let us know your observations after trying this. If the issue persists, you may refer to the link we provided to investigate further: https://stackoverflow.com/questions/24332304/why-do-i-get-culture-is-not-supported-and-what-if-anything-should-i-do-abou

    If the issue is resolved after removing the FpSpread control, please provide us with the specifications of your machine, including the complete OS version.

    Please note that the ‘en-CH’ locale is supported for Windows 10 v1607 operating system and Windows Server 2016 or later versions. Refer here: https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-lcid/a9eac961-e77d-41a6-90a5-ce1a8b0cdb9c?redirectedfrom=MSDN

    We also request you share your machine’s locale settings with us by referring to this link: https://winaero.com/find-current-system-locale-in-windows-10/

    We can provide better assistance once we have these details.

    Thanks & Regards,

    Aastha

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels