I can get the grid to export an euro sign. I get the following export with the code beneath. I have version 2011 Q2 of telerik components.
Unit Price |
€ 100,00 |
<
UserControl
x:Class
=
"silverlightTest.MainPage"
mc:Ignorable
=
"d"
d:DesignHeight
=
"300"
d:DesignWidth
=
"400"
xmlns:telerik
=
"http://schemas.telerik.com/2008/xaml/presentation"
>
<
Grid
x:Name
=
"LayoutRoot"
Background
=
"White"
>
<
telerik:RadGridView
ElementExporting
=
"RadGridView1_ElementExporting"
AutoExpandGroups
=
"True"
x:Name
=
"RadGridView1"
ItemsSource
=
"{Binding RandomProducts}"
ShowColumnFooters
=
"True"
ShowGroupFooters
=
"True"
AutoGenerateColumns
=
"False"
IsReadOnly
=
"True"
CanUserFreezeColumns
=
"False"
CanUserResizeColumns
=
"False"
Margin
=
"0,0,0,74"
>
<
telerik:RadGridView.Columns
>
<
telerik:GridViewDataColumn
Width
=
"200"
Header
=
"Unit Price"
TextAlignment
=
"Right"
DataMemberBinding
=
"{Binding Value}"
DataFormatString
=
"{}{0:c}"
/>
</
telerik:RadGridView.Columns
>
</
telerik:RadGridView
>
<
Button
Content
=
"Button"
Height
=
"23"
HorizontalAlignment
=
"Left"
Margin
=
"26,259,0,0"
Name
=
"button1"
VerticalAlignment
=
"Top"
Width
=
"75"
Click
=
"button1_Click"
/>
</
Grid
>
</
UserControl
>
code behind
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.IO;
using Telerik.Windows.Controls;
using Telerik.Windows.Data;
namespace silverlightTest
{
public partial class MainPage : UserControl
{
public MainPage()
{
InitializeComponent();
RadGridView1.ItemsSource = new List<
MyObject
>() { new MyObject() { Value = 100 } };
}
private void button1_Click(object sender, RoutedEventArgs e)
{
string extension = "";
ExportFormat format = ExportFormat.Html;
string selectedItem = "Excel";
switch (selectedItem)
{
case "Excel": extension = "xls";
format = ExportFormat.Html;
break;
case "ExcelML": extension = "xml";
format = ExportFormat.ExcelML;
break;
case "Word": extension = "doc";
format = ExportFormat.Html;
break;
case "Csv": extension = "csv";
format = ExportFormat.Csv;
break;
}
SaveFileDialog dialog = new SaveFileDialog();
dialog.DefaultExt = extension;
dialog.Filter = String.Format("{1} files (*.{0})|*.{0}|All files (*.*)|*.*", extension, selectedItem);
dialog.FilterIndex = 1;
if (dialog.ShowDialog() == true)
{
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);
}
}
}
private void RadGridView1_ElementExporting(object sender, GridViewElementExportingEventArgs e)
{
if (e.Element == ExportElement.HeaderRow || e.Element == ExportElement.FooterRow
|| e.Element == ExportElement.GroupFooterRow)
{
//e.Background = HeaderBackgroundPicker.SelectedColor;
//e.Foreground = HeaderForegroundPicker.SelectedColor;
e.FontSize = 20;
e.FontWeight = FontWeights.Bold;
}
else if (e.Element == ExportElement.Row)
{
//e.Background = RowBackgroundPicker.SelectedColor;
//e.Foreground = RowForegroundPicker.SelectedColor;
}
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)
{
e.FontFamily = new FontFamily("Verdana");
e.Background = Colors.LightGray;
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);
}
}
}
private string GetAggregates(QueryableCollectionViewGroup group, GridViewDataColumn column)
{
List<
string
> aggregates = new List<
string
>();
foreach (AggregateFunction f in column.AggregateFunctions)
{
foreach (AggregateResult r in group.AggregateResults)
{
if (f.FunctionName == r.FunctionName && r.FormattedValue != null)
{
aggregates.Add(r.FormattedValue.ToString());
}
}
}
return String.Join(",", aggregates.ToArray());
}
}
public class MyObject
{
public decimal Value {get;set;}
}
}