"Culture is not supported" exception received when trying to open encrypted Workbook with Invariant Globalization mode enabled

I’m trying to open and decrypt the attached XLS file with the following code:

public int Decrypt(string inputFile, string password, string outputFile, ref string errMsg)
{
    LoadOptions options = new LoadOptions();
    options.Password = password;

    Workbook doc = new Workbook(inputFile, options);

    for (int idx = 0; idx < doc.Worksheets.Count; idx++)
    {
        if (doc.Worksheets[idx].IsProtected)
        doc.Worksheets[idx].Unprotect(password);
    }

    doc.Unprotect(password);

    doc.Settings.Password = null;
    doc.Save(outputFile, saveFormat);
    return 0;
}

With Invariant Globalization mode disabled for the .Net project. The above code works normally without issue.

But when I try to enable Invariant Globalization, I received the following exception:

Culture is not supported. (Parameter ‘culture’)
1033 (0x0409) is an invalid culture identifier.

This is the stack trace when the issue happens:

at System.Globalization.CultureData.GetCultureData(Int32 culture, Boolean bUseUserOverride)
at System.Globalization.CultureInfo…ctor(Int32 culture, Boolean useUserOverride)
at .(Int16 )
at Aspose.Cells.CustomImplementationFactory.CreateCultureInfo(Int32 lcid)
at .(CountryCode )
at .(CountryCode )
at Aspose.Cells.WorkbookSettings.set_Region(CountryCode value)
at .( )
at .( )
at .(Stream )
at .( , Stream )
at .( , Stream )
at .( , String )
at .()
at .(String , Stream , LoadOptions )
at Aspose.Cells.Workbook.(String , LoadOptions )
at Aspose.Cells.Workbook…ctor(String file, LoadOptions loadOptions)
at ().Decrypt(String inputFile, String password, String outputFile, String& errMsg)

File sample: password.7z (3.7 MB) (Password to decrypt: password.xls)

This issue only happens on Linux, not on Windows. I’m using Aspose Cells version 22.3.

I kinda understand the situation as my sample file contains non-english characters and the invariant globalization feature is enabled.
But I also have other Word and Powerpoints files that has non-english characters as well, but the issue did not happened. Only with Aspose Cells that I have the above exception.

I want to know whether this is the expected behavior and is there any solution to resolve this problem.
Any help regarding this would be really appriciated. Thanks!

@dunghnguyen,

Thanks for the sample file and details.

We need to investigate your issue in details. We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): CELLSNET-53030

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

1 Like

@dunghnguyen,

For performance consideration, we do not add additional check for unsupported CultureInfo when applying regional settings. There are regional settings defined in your xls template file, so when initializing the workbook from it the corresponding CultureInfo is needed.

For your situation, you may implement your own CustomImplementationFactory to override the CreateCultureInfo(int) method. In your implementation you may check(such as using try catch block) whether the required cultureinfo is supported. If not, you may return one which is supported by your environment as replacement.