We make export to Exxel from our GridViews using ExportExtensions.ToCsv(grid, true);
we use it in our function:
public static void ExportToXls(RadGridView grid)
{
SaveFileDialog textDialog = new SaveFileDialog();
textDialog.Filter = "XLS Files | *.csv";
textDialog.DefaultExt = "csv";
bool? result = textDialog.ShowDialog();
if (result == true)
{
System.Text.Encoding ascii = System.Text.Encoding.UTF8;
Encoding enc=Encoding.GetEncoding("cp1251");
string data = ExportExtensions.ToCsv(grid, true);
data = data.Replace(",", ";");
System.IO.Stream fileStream = textDialog.OpenFile();
byte[] contents = enc.GetBytes(data);
fileStream.Write(contents, 0, contents.Length);
fileStream.Flush();
fileStream.Close();
}
}
But when we use different IValueConverters in our grid to convert the data in cells to user friendly data, in csv we see not user friendy data, without impact of IValueConverters.
That's the first problem.
Enother problem is when we use paging in our grid, there is only the current page in our csv file - but there are no other pages!
=(
how can I solve this problems?
17 Answers, 1 is accepted
I'm not sure about these IValueConverter problems however you can send us an example project where we can reproduce this issue. You may need to check our demo to know more how to export paged data.
Best wishes,Vlad
the Telerik team
Indeed the example is for Silverlight 4 however you can use the same approach with Silverlight 3 as well.
Best wishes,Vlad
the Telerik team
I try to export like in the example - http://demos.telerik.com/silverlight/#GridView/ExportingPagedData
i write such usings:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
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.Windows.Navigation;
using System.Text;
using System.IO;
using System.IO.IsolatedStorage;
using System.Globalization;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using Telerik.Windows.Controls.GridView;
using Telerik.Windows.Data;
using Telerik.Windows.Controls;
using System.ServiceModel;
it includes all the includes from the example.
but I have a bug:
on line
GridViewExportOptions exportOptions = new GridViewExportOptions();
such a bug:
The type or namespace name 'GridViewExportOptions' could not be found (are you missing a using directive or an assembly reference?)
and on line:
grStatistics.Export(stream, exportOptions); (grStatistics is a RadGridView)
suuch a bug:
'Telerik.Windows.Controls.RadGridView' does not contain a definition for 'Export' and no extension method 'Export' accepting a first argument of type 'Telerik.Windows.Controls.RadGridView' could be found (are you missing a using directive or an assembly reference?)
what I do wrong?
Do you have our latest Silverlight 3 version?
All the best,Vlad
the Telerik team
This installer database contains the logic and data required to install Telerik RadControls for Silverlight Q3 2009 SP2.
Indeed this is old version and GridViewExportOptions is available only in our latest versions. You can use old ToXXX methods in your case.
Regards,Vlad
the Telerik team
Mike
This demo was removed.
Kind regards,Vlad
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Mike
If your grid is bound to a service you will need to download all the the data to the client which is not the efficient way. It will be better to export on the server-side using Telerik Reporting and download the document directly.
Kind regards,Vlad
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Thanks,
Mike
Indeed you will need to download all the items on the client and use them for exporting.
Regards,Vlad
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Thanks,
Mike
How the grid is bound is your case? Are you using RadDomainDataSource? You can simply create second data source without PageSize set and load the items from the service when needed. Still you should be careful since you may get communication exception if you try to serialize large collection on the client - in such case please check my suggestion in the first reply.
Kind regards,Vlad
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
thanks,
Mike
All you need to do is to call Export() grid method in your RIA service load completed event handler with desired GridViewExportOptions. As you can see this is the exact reason why we've removed this demo - it was just too trivial.
Kind regards,Vlad
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>