This question is locked. New answers and comments are not allowed.
Hi,
I'm using RadControls for Silverlight Q1 2011 and in the process of trying to export data in a Gridview to an excel file. I looked at the demo you have at http://demos.telerik.com/silverlight/#GridView/Exporting and noticed that you can only export to an xls format, what about Excel 2007's xlsx format?
Also, Can you add styling (coloring) to specific cells? What about annotations? Any examples would be fantastic. Thank you.
Rami
I'm using RadControls for Silverlight Q1 2011 and in the process of trying to export data in a Gridview to an excel file. I looked at the demo you have at http://demos.telerik.com/silverlight/#GridView/Exporting and noticed that you can only export to an xls format, what about Excel 2007's xlsx format?
Also, Can you add styling (coloring) to specific cells? What about annotations? Any examples would be fantastic. Thank you.
Rami
3 Answers, 1 is accepted
0
Hi Rami,
The features requested are not supported by RadGridView out-of-the-box.
To achieve such behavior the only way is to modify the output stream when exporting the content of RadGridView.
You can get access to this stream in the Exporting event.
All the best,
Pavel Pavlov
the Telerik team
The features requested are not supported by RadGridView out-of-the-box.
To achieve such behavior the only way is to modify the output stream when exporting the content of RadGridView.
You can get access to this stream in the Exporting event.
All the best,
Pavel Pavlov
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

Rami
Top achievements
Rank 1
answered on 25 Apr 2011, 04:07 PM
Thanks Pavel - do you have any examples on manipulating the output stream through the exporting event?
What about my question regarding exporting to Excel 2007 (.xlsx) format, is that possible in the current version? Thanks again.
Rami
What about my question regarding exporting to Excel 2007 (.xlsx) format, is that possible in the current version? Thanks again.
Rami
0
Hi Rami,
RadGridView does not support Excel2007 format.
Regarding styling /coloring of specific cells - here is some code I took form the online example :
All the best,
Pavel Pavlov
the Telerik team
RadGridView does not support Excel2007 format.
Regarding styling /coloring of specific cells - here is some code I took form the online example :
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());
}
All the best,
Pavel Pavlov
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