Excel 97-2003 file not getting loaded into Aspose

We have multiple files which are Excel97-2003, and we’re using below code to load the file for processing. and its failing to load and throwing excelption.

private void LoadExcelDocument(Stream nativeExcelDocument)
    {
        try
        {
            var loadOptions = new LoadOptions(LoadFormat.Auto);
            //Load stream from file store.
            workbook = new Aspose.Cells.Workbook(nativeExcelDocument, loadOptions);
        }
        catch (Exception ex)
        {
            _logger.LogError("Excel document load failure {@Exception}",ex);
        }
    }

Let us know if any more info is required.

Thanks

@shivanandchikkalli
Could you share some template xls files which could not be loaded ?
We will check them soon .

CHD000001635 (1).zip (4.7 KB)
please find the attached document

@shivanandchikkalli,
By using the latest version Aspose.Cells 23.8 for testing, we can load and resave the file correctly. Please refer to the attachment (11.7 KB).
The sample code as follows:

try
{
    LoadOptions loadOptions = new LoadOptions(LoadFormat.Auto);
    //Load stream from file store.
    Workbook workbook = new Aspose.Cells.Workbook(filePath + "CHD000001635 (1).xls", loadOptions);
    workbook.Save(filePath + "out_net.xlsx");
}
catch (Exception ex)
{
    Console.WriteLine($"{ex.Message}");
}

Hi @John.He,
This is working when while debugging in windows machine, but our application is hosted in docker containers, which uses alpine as base image, where it’s throwing below exception.

    {
  "InvalidCultureId": 4105,
  "InvalidCultureName": null,
  "Message": "Only the invariant culture is supported in globalization-invariant mode. See https://aka.ms/GlobalizationInvariantMode for more information. (Parameter 'culture')n4105 (0x1009) is an invalid culture identifier.",
  "ParamName": "culture",
  "TargetSite": "System.Globalization.CultureData GetCultureData(Int32, Boolean)",
  "Data": [],
  "InnerException": null,
  "HelpLink": null,
  "Source": "System.Private.CoreLib",
  "HResult": -2147024809,
  "StackTrace": "   at System.Globalization.CultureData.GetCultureData(Int32 culture, Boolean bUseUserOverride)n   at System.Globalization.CultureInfo..ctor(Int32 culture, Boolean useUserOverride)n   at u0005u001Bu0002u0002.u0002(Int16 u0002)n   at Aspose.Cells.CustomImplementationFactory.CreateCultureInfo(Int32 lcid)n   at u0005u001Bu0002u0002.u0002(CountryCode u0002)n   at u0002u000Fu0016.u0002(CountryCode u0002)n   at Aspose.Cells.WorkbookSettings.set_Region(CountryCode value)n   at u000Fu0019u0018u0005.u000Eu0005(u0005u001Bu0018u0005 u0002)n   at u000Fu0019u0018u0005.u000Eu0003(u0005u001Bu0018u0005 u0002)n   at u000Fu0019u0018u0005.u000Fu0019u0018u0005u0015u0015u0002(Stream u0002)n   at u000Fu0019u0018u0005.u0002(u0005u0016u001Au0005 u0002, Stream u0003)n   at u000Fu0019u0018u0005.u0003(u0005u0016u001Au0005 u0002, Stream u0003)n   at u0005u0019u0002.u0003(u0005u0016u001Au0005 u0002, String u0003)n   at u0005u0019u0002.u0002()n   at u0005u0019u0002.u0002(String u0002, Stream u0003, LoadOptions u0005)n   at Aspose.Cells.Workbook.u0002(Stream u0002, LoadOptions u0003, Boolean u0005)n   at Aspose.Cells.Workbook..ctor(Stream stream, LoadOptions loadOptions)n   at SampleProject.BLL.Excel.Workbook.WorkbookBLL.LoadExcelDocument(Stream nativeExcelDocument) in /src/SampleProject/BLL/Excel/Workbook/WorkbookBLL.cs:line 295",
  "$type": "CultureNotFoundException"
}

@shivanandchikkalli,

For such environment, would you please try the solution of implementing your own factory for creating CultureInfo by CustomImplementationFactory.CreateCultureInfo and setting your implementation to CellsHelper.CustomImplementationFactory. In your implementation, you may just catch the exception and return some kind of existing cultureinfo as default. The code example:

        class MyImplementation : CustomImplementationFactory
        {
            public override CultureInfo CreateCultureInfo(int lcid)
            {
                try
                {
                    return base.CreateCultureInfo(lcid);
                }
                catch
                {
                    return CultureInfo.CurrentCulture;
                }
            }
        }

        CellsHelper.CustomImplementationFactory = new MyImplementation();
        Workbook workbook...
        ...