I copied from an excel file to a txt file the column names. I read from the txt file the following way:
CultureInfo cultureHU;
Encoding encodingHU;
cultureHU = CultureInfo.GetCultureInfo("hu-HU");
encodingHU = Encoding.GetEncoding(cultureHU.TextInfo.ANSICodePage);
using (StreamReader sr = new StreamReader("settings.txt", encodingHU, true))
{
...
}
How do I read from an Excel file with the same encoding? If I do it the default way (xlRange.Cells[1, i].Value.ToString()), then I get wrong values:
- in the excel and txt file I have: "Szerzõdõ"
- reading from the text file in encodingHU encoding I get: "Szerződő" (this is the correct format)
- reading from excel in C# i get: "Szerzõdõ"