This is a migrated thread and some comments may be shown as answers.

Problems with nordic characters in CSV import, encoding related maybe?

2 Answers 410 Views
Spreadsheet
This is a migrated thread and some comments may be shown as answers.
aron
Top achievements
Rank 1
aron asked on 30 Jan 2019, 11:50 AM

When uploading a CSV file containing nordic characters such as Å,Ä,Ö the spreadsheet fails to accurately represent them. 

This also does not work in your demo https://demos.telerik.com/aspnet-mvc/spreadsheet/server-side-import-export when uploading a file that looks like this:

1.Id,Namn,Förslag,Åtgärd
2.0,Åsä Löåfv,Lorem ipsum,Lörem ipsåm

Row  #1 is the header of the CSV, Row #2 is example data. As you can see in your own demo, importing this file into the spreadsheet does not work, the ÅÄÖ characters get represented as ? which later breaks other stuff in my application (when parsing the spreadsheet). Any idea on how to maintain these characters?

 

2 Answers, 1 is accepted

Sort by
0
Accepted
Veselin Tsvetanov
Telerik team
answered on 01 Feb 2019, 08:54 AM
Hi Aron,

The issue faced is caused by the default encoding applied to the Telerik Document Processing CsvFormatProvider, which is used internally by the Telerik.Web.Spredsheet.Workbook.Load() method. In order to resolve that issue you will need to manually create that format provider and pass the proper encoding configuration to it. As a consequence, that Upload Controller action needs to be modified to:
[HttpPost]
public ActionResult Upload(HttpPostedFileBase file)
{
    var fileFormatProvider = new CsvFormatProvider();
    fileFormatProvider.Settings.Encoding = Encoding.GetEncoding(1257);
    Telerik.Windows.Documents.Spreadsheet.Model.Workbook document = fileFormatProvider.Import(file.InputStream);
 
    var workbook = Workbook.FromDocument(document);
    return Content(workbook.ToJson(), Telerik.Web.Spreadsheet.MimeTypes.JSON);
}

Attached you will find a small sample implementing the above.

I hope that this helps.

Regards,
Veselin Tsvetanov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
aron
Top achievements
Rank 1
answered on 01 Feb 2019, 10:49 AM
Thanks! I figured it had something to do with encoding!
Tags
Spreadsheet
Asked by
aron
Top achievements
Rank 1
Answers by
Veselin Tsvetanov
Telerik team
aron
Top achievements
Rank 1
Share this question
or