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

Export of chinese characters ...

9 Answers 114 Views
GridView
This is a migrated thread and some comments may be shown as answers.
scott
Top achievements
Rank 1
scott asked on 20 Sep 2010, 09:19 PM
Hello...

I've got columns in a grid that display the correct unicode stuff for data coming out of asia. When this is exported to CSV or DOC or HTML the format is gone.  This is a city in china named Kunming:  昆明市  and this displays great on the screen, but once exported it looks like:

昆明市

It doesn't seem to matter what font I try.

Does this not work or am I doing something wrong ?

Thanks -
Scott

9 Answers, 1 is accepted

Sort by
0
Yavor Georgiev
Telerik team
answered on 21 Sep 2010, 10:16 AM
Hello scott,

 I'm afraid I was unable to reproduce your problem. Could you please post a few snippets of your code? Where does the data come from?

Sincerely yours,
Yavor Georgiev
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
scott
Top achievements
Rank 1
answered on 21 Sep 2010, 03:24 PM
Hi Yavor.  Here's a reproducer...

<UserControl x:Class="chineseCharactersForumPost.MainPage"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">
  
    <Grid x:Name="LayoutRoot" Background="White">
        <StackPanel>
            <telerik:RadGridView Name="myGrid" ItemsSource="{Binding}"/>
            <telerik:RadButton Content="Click Me to Export CSV File" Click="CSV_Click"/>
            <telerik:RadButton Content="Click Me to Export DOC File" Click="DOC_Click"/>
            <telerik:RadButton Content="Click Me to Export HTML File" Click="HTML_Click"/>
        </StackPanel>
    </Grid>
</UserControl>

And...

using System.Collections.Generic;
using System.IO;
using System.Windows;
using System.Windows.Controls;
  
using Telerik.Windows.Controls;
  
namespace chineseCharactersForumPost
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
            myGrid.ItemsSource = ViewModel();
        }
  
        List<string> ViewModel()
        {
            return new List<string>() { "石家庄市", "广东南山区", "天津" };
        }
  
        private void CSV_Click(object sender, RoutedEventArgs e)
        {
            Export("CSV");
        }
  
        private void DOC_Click(object sender, RoutedEventArgs e)
        {
            Export("DOC");
        }
  
        private void HTML_Click(object sender, RoutedEventArgs e)
        {
            Export("HTML");
        }
  
        void Export(string x)
        {
            SaveFileDialog dialog = new SaveFileDialog();
            dialog.DefaultExt = x;
            dialog.Filter = string.Format("{1} File (*.{0}) | *.{0}", x, x);
  
            if (!(bool)dialog.ShowDialog())
                return;
  
            Stream fileStream = dialog.OpenFile();
            ExportTheFile(fileStream, x);
            fileStream.Close();
        }
  
        private void ExportTheFile(Stream fileStream, string x)
        {
            ExportFormat format;
            switch (x)
            {
                case "HTML":
                    format = ExportFormat.Html;
                    break;
                case "CSV":
                    format = ExportFormat.Csv;
                    break;
                case "DOC":
                    format = ExportFormat.Html;
                    break;
                default:
                    format = ExportFormat.Html;
                    break;
            }
  
            GridViewExportOptions options = new GridViewExportOptions();
            options.Format = format;
            options.ShowColumnFooters = true;
            options.ShowColumnHeaders = true;
            options.ShowGroupFooters = true;
            myGrid.Export(fileStream, options);
        }
  
  
    }
}





0
Yavor Georgiev
Telerik team
answered on 21 Sep 2010, 03:46 PM
Hello scott,

 This happens only when you export to HTML and is rather the fault of the viewer you use. If you opened the resulting .html file with an editor such as Notepad++ you'll see that the chinese characters are indeed intact. However, you'll notice that the HTML file is not complete, but only a fragment. You need to complete the fragment and add a "meta" tag in the HTML document's Head, which tells the browser (or MS Word) to use Unicode to display the data:
<html>
<head>
<meta http-equiv=content-type content="text/html; charset=UTF-8">
</head>
<body>
<table style="border-collapse:collapse" border="1">
<tr>
<td style="width:65">String</td></tr>
<tr>
<td>石家庄市</td></tr>
<tr>
<td>广东南山区</td></tr>
<tr>
<td>天津</td></tr>
<tr>
<td></td></tr>
</table>
</body>
</html>

Greetings,
Yavor Georgiev
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
scott
Top achievements
Rank 1
answered on 21 Sep 2010, 03:52 PM
I figured it was me ...

I can't see the chinese stuff in a CSV file via Excel either, and thats what my customer is complaining about.  When I open the CSV in a vanilla notepad I can see the chinese stuff just fine.   Do you have a workaround for excel as well ?

Thanks for the super fast response -
Scott

0
Accepted
Yavor Georgiev
Telerik team
answered on 21 Sep 2010, 04:01 PM
Hello scott,

 You need to tell Excel to open the file with Unicode encoding, but that depends on the version of Microsoft Excel your client is using. In Excel 2010 you do this from the From Text option in the Data ribbon tab. I'm not sure about previous versions of Excel, though.

Greetings,
Yavor Georgiev
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
scott
Top achievements
Rank 1
answered on 21 Sep 2010, 04:03 PM
Thanks for the tip - I'm testing on 2007 so let me hunt that information down.  You guys rock.
0
Milinda
Top achievements
Rank 1
answered on 20 Apr 2018, 10:03 AM

Helloo,

My problem is Swedish characters are not rendering properly when export to PDF.

Is there any special way of doing this?

Thanks

Prasanna

0
Milinda
Top achievements
Rank 1
answered on 20 Apr 2018, 10:52 AM

Hi,

Sweden characters are not rendering after export to PDF.

Is there any special way of doing this?

Thanks,

Milinda

0
Dinko | Tech Support Engineer
Telerik team
answered on 25 Apr 2018, 08:53 AM
Hello Milinda,

I have tested the described behavior but wasn't able to reproduce it on my side. I am attaching the sample project which I used to test your scenario. Can you give it a try and let me know what I need to modify so it reproduces this behavior? Can you also elaborate more on what do you mean that is not rendered?

Regards,
Dinko
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
GridView
Asked by
scott
Top achievements
Rank 1
Answers by
Yavor Georgiev
Telerik team
scott
Top achievements
Rank 1
Milinda
Top achievements
Rank 1
Dinko | Tech Support Engineer
Telerik team
Share this question
or