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

Problem with German umlaut letters when exporting to Excel, HTML

11 Answers 784 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Herr
Top achievements
Rank 2
Herr asked on 28 Oct 2010, 09:56 AM
Hello,

I am using RadControls_for_WPF35_2010_2_0812_DEV,

When I create a analysis in our solution, i can not exporting this analysis with umlaut letters (Ä,Ü,ß etc.) to excel, html.
Could you help me to fix the problem?

We uses your Export Excel Snippet of your WPF Demo.

#region Export2Excel
private byte groupCount = 0;
private void RadButton_Click(object sender, RoutedEventArgs e)
{
    groupCount = 1;
    string extension = "xls";
    string extension2 = "html";
    var format = ExportFormat.Html;
 
    SaveFileDialog dialog = new SaveFileDialog();
    dialog.DefaultExt = extension;
    dialog.Filter = String.Format("{1} files (*.{0})|*.{0}|{3} files (*.{2})|*.{2}", extension, "Excel", extension2, "HTML");
    dialog.FilterIndex = 1;
 
    if (dialog.ShowDialog() == true)
    {
        if (dialog.FilterIndex == 1)
        {
            using (Stream stream = dialog.OpenFile())
            {
                GridViewExportOptions exportOptions = new GridViewExportOptions();
                exportOptions.Format = format;
                exportOptions.ShowColumnFooters = true;
                exportOptions.ShowColumnHeaders = true;
                exportOptions.ShowGroupFooters = true;
                RadGridView1.Export(stream, exportOptions);
            }
        }
        else
        {
            var str = RadGridView1.ToHtml(true, true);
            var f = File.CreateText(dialog.FileName);
            f.Write(str);
            f.Close();
        }
    }
}
private void RadGridView1_ElementExporting(object sender, GridViewElementExportingEventArgs e)
{
    byte faktor = 10;
    Color groupBGCol = Colors.DarkGray;
    if (e.Element == ExportElement.HeaderRow || e.Element == ExportElement.FooterRow)
    {
        e.Background = Colors.DarkGray;
        e.Foreground = Colors.Black;
        e.FontSize = 20;
        e.FontWeight = FontWeights.Bold;
    }
    else if (e.Element == ExportElement.GroupFooterRow)
    {
        groupCount--;
        groupBGCol.R += Convert.ToByte(groupCount * faktor);
        groupBGCol.G += Convert.ToByte(groupCount * faktor);
        groupBGCol.B += Convert.ToByte(groupCount * faktor);
        e.Background = groupBGCol;
        e.Foreground = Colors.Black;
        e.FontSize = 20;
        e.FontWeight = FontWeights.Bold;
    }
    else if (e.Element == ExportElement.Row)
    {
        e.Background = Colors.LightGray;
        e.Foreground = Colors.Black;
    }
    else if (e.Element == ExportElement.Cell &&
        e.Value != null && e.Value.Equals("Chocolade"))
    {
        e.FontFamily = new FontFamily("Verdana");
        e.Background = Colors.LightGray;
        e.Foreground = Colors.Blue;
    }
    else if (e.Element == ExportElement.GroupHeaderRow)
    {
        groupCount++;
        groupBGCol.R += Convert.ToByte(groupCount * faktor);
        groupBGCol.G += Convert.ToByte(groupCount * faktor);
        groupBGCol.B += Convert.ToByte(groupCount * faktor);
        e.FontFamily = new FontFamily("Verdana");
        e.Background = groupBGCol;
        e.Height = 30;
    }
    else if (e.Element == ExportElement.GroupHeaderCell &&
        e.Value != null && e.Value.Equals("Chocolade"))
    {
        e.Value = "MyNewValue";
    }
    else if (e.Element == ExportElement.GroupFooterCell)
    {
        GridViewDataColumn column = e.Context as GridViewDataColumn;
        QueryableCollectionViewGroup qcvGroup = e.Value as QueryableCollectionViewGroup;
 
        if (column != null && qcvGroup != null && column.AggregateFunctions.Count() > 0)
        {
            e.Value = GetAggregates(qcvGroup, column);
        }
        else
            e.Value = string.Empty;
    }
    if (e.Value != null)
    {
        DateTime tmp;
        if (DateTime.TryParse(e.Value.ToString(), out tmp))
        {
            e.Value = tmp.ToShortDateString();
        }
 
    }
}

Best regards,
Michael

11 Answers, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 28 Oct 2010, 10:25 AM
Hi Michael,

Can you please open the exported file with Notepad and check whether these letters are correctly displayed there? Let me know.

Regards,
Veselin Vasilev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Herr
Top achievements
Rank 2
answered on 28 Oct 2010, 10:33 AM
Hi Veselin,
these letters are correctly displayed in Wordpad. What comes next?
<tr style="background:#A9A9A9;color:#000000;font-size:20;font-weight:Bold">
<td style="width:132,813333333333">Objekt Kennung</td><td style="width:117,66">Bezeichnung</td><td style="width:113,93">Gebäudetyp</td><td style="width:85,1833333333333">Status</td><td style="width:87,01">Straße</td><td style="width:74,1733333333333">PLZ</td><td style="width:79,6833333333333">Stadt</td><td style="width:112,16">Bundesland</td><td style="width:130,446666666667">Länderkennung</td><td style="width:126,206666666667">Buchungskreis</td><td style="width:114,046666666667">Kostenstelle</td><td style="width:95,58">Standort</td><td style="width:110,246666666667">Bemerkung</td><td style="width:110,246666666667">Bemerkung</td><td style="width:110,246666666667">Bemerkung</td><td style="width:110,246666666667">Bemerkung</td><td style="width:129,273333333333">Grundbuchblatt</td><td style="width:139,02">Flurstücknummer</td><td style="width:138,976666666667">Grundstückgröße</td><td style="width:176,37">Objektnummer Immobilie</td><td style="width:79,2533333333333">Kurzbez. Immobilie</td><td style="width:79,2533333333333">Langbez. Immobilie</td><td style="width:41,64">Sprinkler-Rabatt</td><td style="width:63,0466666666667">Eröffnungsdatum</td><td style="width:63,0466666666667">Übernahmedatum</td><td style="width:32,4666666666667">Baujahr</td><td style="width:124,94">Email</td><td style="width:32,4666666666667">Meldefrist in h</td><td style="width:55,6966666666667">Referenz</td></tr>
<tr style="background:#D3D3D3;color:#000000">
<td>200106</td><td>gasthaus</td><td>Verwaltungsgebäude</td><td>Aktiv</td><td> </td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>0,00</td><td></td><td></td><td></td><td>0,00</td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr style="background:#D3D3D3;color:#000000">


Best regards,
Michael
0
Veselin Vasilev
Telerik team
answered on 28 Oct 2010, 02:18 PM
Hello Michael,

This is what I expected. It seems Excel does not show these letters properly when opening html file.

Can you please try to export them in ExcelML format? Would it be feasible for you?


Sincerely yours,
Veselin Vasilev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Veselin Vasilev
Telerik team
answered on 28 Oct 2010, 03:01 PM
Hello Michael,

This is what I expected. It seems Excel does not show these letters properly when opening html file.

Can you please try to export them in ExcelML format? Would it be feasible for you?


Sincerely yours,
Veselin Vasilev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Herr
Top achievements
Rank 2
answered on 28 Oct 2010, 03:17 PM
Hi Veselin,

with the ExcelML Format I have the same problem. The umlaut letters cannot exporting.

Regards,
Michael
0
Accepted
Veselin Vasilev
Telerik team
answered on 28 Oct 2010, 03:32 PM
Hello Michael,

Actually, there is a way to overcome the problem.

using (Stream stream = dialog.OpenFile())
{
    GridViewExportOptions exportOptions = new GridViewExportOptions();
    exportOptions.Format = format;
    exportOptions.ShowColumnFooters = true;
    exportOptions.ShowColumnHeaders = true;
    exportOptions.ShowGroupFooters = true;
  
    byte[] buffer = Encoding.UTF8.GetBytes("<meta charset=\"utf-8\">");
    stream.Write(buffer, 0, buffer.Length);
  
  
    clubsGrid.Export(stream, exportOptions);
}

Hope this helps.

Sincerely yours,
Veselin Vasilev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Herr
Top achievements
Rank 2
answered on 28 Oct 2010, 04:17 PM
Hello,

This worked for me!
Thank you very much!


Best wishes,
Michael
0
Jay
Top achievements
Rank 1
answered on 11 Jun 2014, 01:36 PM
Hi there,

we're having the same issue with the CSV export.
Any suggestions how to get Umlauts properly working there?

Cheers,
Jay
0
Dimitrina
Telerik team
answered on 16 Jun 2014, 07:04 AM
Hello Jay,

Does specifying an Encoding not work for you? You can also try specifying encoding of the exported data to be Unicode through the ExportOptions.Encoding property. 

Generally putting <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
at the top of the HTML, should cause the letters to display correctly. 

Regards,
Didie
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Jens
Top achievements
Rank 1
answered on 05 Aug 2015, 07:44 AM

I'm having the same Umlaut issues with the PDF Export using the PdfFormatProvider.
Is this a bug or am I missing a setting?

Cheers,
Jens

0
Deyan
Telerik team
answered on 05 Aug 2015, 01:35 PM
Hello Jens,

You may see the answer to your question in this forum post.

Regards,
Deyan
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
GridView
Asked by
Herr
Top achievements
Rank 2
Answers by
Veselin Vasilev
Telerik team
Herr
Top achievements
Rank 2
Jay
Top achievements
Rank 1
Dimitrina
Telerik team
Jens
Top achievements
Rank 1
Deyan
Telerik team
Share this question
or