ExcelDataReader – No data is available for encoding 1252

Contents
During the last month, I had to convert an xlsx file to csv in a netcore Azure Function, and I discovered how it should have been simple!
In theory, I only have to read the file with ExcelDataReader and after write the file as text.
It should have been an easy thing to do, but suddenly I recognized that some file worked and other not.
What was the error? A message “NotSupportedException: No data is available for encoding 1252” appeared. How could I solve it?
The solution has been very simple to find.
- Add “System.Text.Encoding.CodePages” NuGet package to solution
- Open the file Startup.cs > ConfigureServices and change as in the snippet
Startup - ConfigureServices
|
|
That’s the easiest way to read an excel file without problem from netcore code.
Links