Problem with German umlaut letters when exporting to Excel, HTML

12 posts, 1 answers
  1. Herr
    Herr avatar
    23 posts
    Member since:
    Feb 2009

    Posted 28 Oct 2010 Link to this post

    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
  2. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 28 Oct 2010 Link to this post

    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
  3. UI for WPF is Visual Studio 2017 Ready
  4. Herr
    Herr avatar
    23 posts
    Member since:
    Feb 2009

    Posted 28 Oct 2010 Link to this post

    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
  5. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 28 Oct 2010 Link to this post

    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
  6. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 28 Oct 2010 Link to this post

    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
  7. Herr
    Herr avatar
    23 posts
    Member since:
    Feb 2009

    Posted 28 Oct 2010 Link to this post

    Hi Veselin,

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

    Regards,
    Michael
  8. Answer
    Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 28 Oct 2010 Link to this post

    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
  9. Herr
    Herr avatar
    23 posts
    Member since:
    Feb 2009

    Posted 28 Oct 2010 Link to this post

    Hello,

    This worked for me!
    Thank you very much!


    Best wishes,
    Michael
  10. Jay
    Jay avatar
    8 posts
    Member since:
    Feb 2014

    Posted 11 Jun 2014 Link to this post

    Hi there,

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

    Cheers,
    Jay
  11. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 16 Jun 2014 Link to this post

    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.
     
  12. Jens
    Jens avatar
    19 posts
    Member since:
    Aug 2014

    Posted 05 Aug 2015 Link to this post

    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

  13. Deyan
    Admin
    Deyan avatar
    136 posts

    Posted 05 Aug 2015 Link to this post

    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
Back to Top
UI for WPF is Visual Studio 2017 Ready