EPPlus error reading file
Asked Answered
G

2

-1

using code like

using OfficeOpenXml;  // namespace for the ExcelPackage assembly
…
FileInfo newFile = new FileInfo(@"C:\mynewfile.xlsx"); 
using (ExcelPackage xlPackage = new ExcelPackage(newFile)) { … }

I get an exception error of

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

Any ideas as to what the problem could be?

Thanks Martin

Giamo answered 20/6, 2017 at 17:27 Comment(2)
I have got it to workGiamo
post an answer so others have some use of it tooExclaim
G
8

if your project is .net core edit your project file then add

<ItemGroup>
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.3.0" />
</ItemGroup>

and in your startup.cs

add

System.Text.Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
Gamali answered 17/3, 2019 at 21:8 Comment(1)
I have it in the startup constructor and it works! thanks!Parts
P
3

The problem is in the ZIP file reader (ZipInputStream). You need to add the encodings like windows-1252 manually:

  1. dotnet add package System.Text.Encoding.CodePages

  2. Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);

More info here: .NET Core doesn't know about Windows 1252, how to fix?

Protestantism answered 16/9, 2017 at 23:37 Comment(1)
Where do you apply these steps ??Kami

© 2022 - 2024 — McMap. All rights reserved.