We are building a new experience for our SmartBear Community.
This site is now read-only. You can still browse and search as usual. Learn More
This site is now read-only. You can still browse and search as usual. Learn More
Hi Everyone,
I need to export the results contained in a RadTreeListView object.
There is a lot of data inside and i can't afford to process cells and rows one by one (in terms of testing time)
I see that RadTreeListView object give access to the method:
Export(System.IO.Stream stream, Telerik.Windows.Controls.GridViewExportOptions options)
The only issue I get is to provide the seconde parameter define in this http://docs.telerik.com/devtools/silverlight/controls/radgridview/export/export
I have the Telerik DLL library if needed.
Is there a way to provide the GridViewExportOptions to the method?
Thanks!
Try using the dotNET object obtained directly from the tree list object. Maybe the global dotNET object uses a different .NET version than that used in the app, and that causes conflicts.
Also note that Export needs a Stream object, not a StreamWriter. A FileStream should work.
var dotNET2 = RootApp.Grid.ContentControl.ContentPresenter.RadTreeListView.ClrAppDomain.dotNET;
// Use dotNET2 to create parameters for the Export method call // Initialize GridViewExportOptions var options = dotNET2.Telerik_Windows_Controls.GridViewExportOptions.zctor(); options.Encoding = dotNET2.System_Text.Encoding.Unicode; options.ShowColumnHeaders = true; options.ShowColumnFooters = true; // Initialize the FileStream var fileStream = dotNET2.System_IO.File.Create(path); RootApp.Grid.ContentControl.ContentPresenter.RadTreeListView.Export(fileStream, options); fileStream.Close();
You can create a GridViewExportOptions object like this:
// JScript
// Get the dotNET object from the app,
// so that it's compatible with the app's .NET version var dotNET2 = Sys.Process("YourApp").AppDomain("YourApp.exe").dotNET; var options = dotNET2.Telerik_Windows_Controls.GridViewExportOptions.zctor(); options.Format = dotNET2.Telerik_Windows_Controls.ExportFormat.Xlsx; options.Encoding = dotNET2.System_Text.Encoding.Unicode; options.ShowColumnHeaders = true;
Thousands thanks for you answer HKosova!
I did not know about this trick, it will help me a lot in the future.
Unfortunately i am getting exception while calling the Export method.
Here is the exception:
//Initialize GridViewExportOptions
var dotNET2=Aliases.MachiningCloudApp.AppDomain("MachiningCloudApp.exe").dotNET;
var options = dotNET2.Telerik_Windows_Controls.GridViewExportOptions.zctor();
options.Format = dotNET2.Telerik_Windows_Controls.ExportFormat.Csv;
options.Encoding = dotNET2.System_Text.Encoding.Unicode;
options.ShowColumnHeaders = true;
options.ShowColumnFooters= true;
//Initialize the StreamWriter
var sw =dotNET.System_IO.StreamWriter.zctor_5(path);
sw.AutoFlush=true;
//Call Export method (RootApp represents the parent aliases). RootApp.Grid.ContentControl.ContentPresenter.RadTreeListView.Export(sw,options);
//Close the stream
sw.Close();
I am not really sure if i missed somthing or if the issue is on the app side.
Thanks for you help!
Try using the dotNET object obtained directly from the tree list object. Maybe the global dotNET object uses a different .NET version than that used in the app, and that causes conflicts.
Also note that Export needs a Stream object, not a StreamWriter. A FileStream should work.
var dotNET2 = RootApp.Grid.ContentControl.ContentPresenter.RadTreeListView.ClrAppDomain.dotNET;
// Use dotNET2 to create parameters for the Export method call // Initialize GridViewExportOptions var options = dotNET2.Telerik_Windows_Controls.GridViewExportOptions.zctor(); options.Encoding = dotNET2.System_Text.Encoding.Unicode; options.ShowColumnHeaders = true; options.ShowColumnFooters = true; // Initialize the FileStream var fileStream = dotNET2.System_IO.File.Create(path); RootApp.Grid.ContentControl.ContentPresenter.RadTreeListView.Export(fileStream, options); fileStream.Close();