LoginSignup
1
0

More than 1 year has passed since last update.

System.ArgumentException: ''IBM437' is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method. Arg_ParamName_Name'

Posted at

System.ArgumentException: ''IBM437' is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method. Arg_ParamName_Name'

'IBM437' はサポートされているエンコーディング名ではありません。カスタムエンコーディングの定義については、Encoding.RegisterProvider メソッドのドキュメントを参照してください。

.NET6の開発でExcelライブラリのEPPlusv4を使用したところ、Excelをバイト配列に書き出す時点でエラーが発生した

原因

.NET Core以降ではIBM437エンコーディングがネイティブでサポートされていない
.NET Frameworkまでと.NET Core以降の差異によるもの

解決方法

nugetでSystem.Text.Encoding.CodePagesを追加

dotnet add package System.Text.Encoding.CodePages --version 7.0.0

Encoding.RegisterProvider(CodePagesEncodingProvider.Instance)の記述を追加

using OfficeOpenXml;

Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);

using (var package = new ExcelPackage())
{
 // do something
}

Reference

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0