I have a problem with retrieving data from .csv file (windows-1251 encoding). I use Aspose Cells and here is my code:
public static IEnumerable<ElmarketByExcelModel> ElmarketByParce(string filePath)
{
if (String.IsNullOrEmpty(filePath))
throw new ArgumentException("should be not null", "filePath");
//Opening an existing workbook
var workbook = new Workbook(filePath);
//Accessing first worksheet
var worksheet = workbook.Worksheets[0];
var cells = worksheet.Cells;
var list = new List<ElmarketByExcelModel>(worksheet.Cells.Rows.Count);
for (var i = 2; i < cells.Rows.Count + 1; i++)
{
var model = new ElmarketByExcelModel();
var value = cells["A" + i].Value.ToString();
var newValue = GetString(Encoding.Convert(Encoding.GetEncoding(workbook.Settings.Encoding.HeaderName), Encoding.Default, GetBytes(value)));
var values = newValue.Split(';');
foreach (var val in values)
{
Console.WriteLine(val);
}
list.Add(model);
}
return list.AsEnumerable();
}
When I try to get data from the cell, I get a string with a strange characters
I've tried to change the encoding to different encodings, but that does not help. Can you help me to solve this problem, please?