System.NotSupportedException: No data is available for encoding 1252

后端 未结 2 1651
渐次进展
渐次进展 2021-01-01 10:18

I\'m working with a Trust Commerce Tutorial on how to generate a payment token that will allow customers to use the TC Trustee Host payment form. I was given an example on h

2条回答
  •  自闭症患者
    2021-01-01 11:04

    What ckuri said. Just to be clear, you need the following line of code before opening the stream (steps 2,3):

    System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);

    ExcelDataReader - Important note on .NET Core

    By default, ExcelDataReader throws a NotSupportedException "No data is available for encoding 1252." on .NET Core.

    To fix, add a dependency to the package System.Text.Encoding.CodePages and then add code to register the code page provider during application initialization (f.ex in Startup.cs):

    System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);

    This is required to parse strings in binary BIFF2-5 Excel documents encoded with DOS-era code pages. These encodings are registered by default in the full .NET Framework, but not on .NET Core.

提交回复
热议问题