I've got a stream coming from Azure Blob Storage which is a CSV file.
I open that stream using
var workbook = _application.Workbooks.Open(stream);
and then I export the contents to a class:
var data = sheet.ExportData<T>(1, 1, usedRange.LastRow, usedRange.LastColumn, mappingProperties);
But when the CSV file contains extended ascii characters like Šašiæ the result is aiæ
Only a few extended ascii characters are read properly.
While testing with the original file I found this is working:
using (var r = new StreamReader(filename, Encoding.GetEncoding(1252)))
{
_output.WriteLine(r.ReadToEnd());
}
So I changed my Workbooks.Open as well:
var workbook = _application.Workbooks.Open(stream, Encoding.GetEncoding(1252));
But now
var data = sheet.ExportData<T>(1, 1, usedRange.LastRow, usedRange.LastColumn, mappingProperties);
returns no data, because all data is in the first cell of each row. They are not separated.
I already set:
_application.CSVSeparator = ";";
_application.PreserveCSVDataTypes = true;
My question:
How do I read a CSV file with special encoding but still separate the data in several columns.