Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Blazor: System.NotSupportedException: Encoding 1252 data could not be found

I'm trying to create a workbook using Aspose on a button click, but I immediately run into errors when trying to instantiate the workbook:

Blazor is running in dev mode without IL stripping. To make the bundle size significantly smaller, publish the application or see https://go.microsoft.com/fwlink/?linkid=870414
blazor.webassembly.js:1 WASM: Hello from C#
blazor.webassembly.js:1 WASM: 
blazor.webassembly.js:1 WASM: Unhandled Exception:
d.printErr @ blazor.webassembly.js:1
blazor.webassembly.js:1 WASM: System.NotSupportedException: Encoding 1252 data could not be found. Make sure you have correct international codeset assembly installed and enabled.
d.printErr @ blazor.webassembly.js:1
blazor.webassembly.js:1 WASM:   at System.Text.Encoding.GetEncoding (System.Int32 codepage) <0x3538bc0 + 0x00316> in <d9c16b0fee7344919775df5988c885d0>:0 

FetchData.razor:

<button class="btn btn-primary" @onclick="DownloadFile">Download</button>

@code {
    WeatherForecast[] forecasts;

    protected override async Task OnInitializedAsync()
    {
        forecasts = await Http.GetJsonAsync<WeatherForecast[]>("sample-data/weather.json");
    }

    private async void DownloadFile()
    {
        Console.WriteLine("Hello from C#");

        var wb = new Aspose.Cells.Workbook();

        Console.WriteLine("Created Workbook");

        MemoryStream ms = new MemoryStream();
        wb.Save(ms, Aspose.Cells.SaveFormat.Xlsx);
        byte[] bytes = new byte[ms.Length];
        ms.Read(bytes, 0, bytes.Length);

        Console.WriteLine("Buffed Bytes, sending...");

        await JS.InvokeVoidAsync("saveAsFile", "testWorkbook2.xlsx", bytes);
    }
}

Startup.cs

    public class Startup
    {
        public void ConfigureServices(IServiceCollection services)
        {
            System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
        }

        public void Configure(IComponentsApplicationBuilder app)
        {
            app.AddComponent<App>("app");
        }
    }

dotnet version

λ dotnet --version
3.0.100-preview9-014004

As you can see, I'm trying to add the code pages with System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance); in startup.cs but clearly they're not getting loaded. What am I doing wrong here?

Reference: https://github.com/aspnet/Blazor/issues/1338

like image 499
thefoxrocks Avatar asked Dec 27 '25 15:12

thefoxrocks


1 Answers

I am afraid that Aspose.Cell does not support asp.net core nor core 3.0 blazor project now.You could confirm that to the product support forum.Refer to

https://forum.aspose.com/t/net-core-2-0-support-by-aspose-cells-libraries/16079

https://forum.aspose.com/t/aspose-diagram-codepage-error-only-on-net-core/177961

https://www.nuget.org/packages/Aspose.Cells/

like image 134
Ryan Avatar answered Dec 31 '25 05:12

Ryan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!