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

Export a Hierarchical Grid via ExportAsync as EXCELML format with an xml extesion.

4 Answers 88 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Sintayehu
Top achievements
Rank 1
Sintayehu asked on 04 Apr 2014, 11:09 PM
Hello,

I am trying to use the grids Export Async functionality and here are 4 questions / obstacles I have.

Please feel free to ignore question #1 as it is a Microsoft question.


*********1***********

I am opening a windows SaveFileDialog from a click event and I am setting a DefaultFileName.

1-1 Setting a default file name introduces a modal windows popup that says Title:"File Download - Security Warning Content " Content:"Do you want to save *** file?" I know this is a microsoft thing but was wondering if anyone knows how to directly go to the SaveFileDialog and have DefaultFileName at the same time.

1-2 I tried this with a command bound to the Button and I get a "Dialog must be opened from a user initiated request". Are commands not used initiated? Or am I missing soemething?

var dialog = new SaveFileDialog()
{
DefaultExt = "xml",
Filter = "Excel Workbook (.xml)|*.xml",
DefaultFileName = "sample" + DateTime.Now.ToString("_MM_dd_yyyy_HH_mm_ss") // without this annoying popup doesn't exist but this is useful :)
};

if (dialog.ShowDialog() == true)
{
//do cool stuff here
}


********2************
I am using ExportAsync function of the Grid and I noticed that this function is significantly slower than Export (which uses the UI thread)
 - Is this a known issue? Any recomendations?

//Slow
SampleRadGridView.ExportAsync(sameExactStream,
new GridViewExportOptions()
{
Format = ExportFormat.Html,
ShowColumnHeaders = true,
ShowColumnFooters = true,
ShowGroupFooters = true,
}, true);
**********************************************
VS
**********************************************
//Fast
SampleRadGridView.Export(sameExactStream,
new GridViewExportOptions()
{
Format = ExportFormat.ExcelML,
ShowColumnHeaders = true,
ShowColumnFooters = true,
ShowGroupFooters = true
});



********3************
As recomended in the documentation to avoid an excel security warning upon opening an exported file, I am setting my GridViewExportOption.Format to EXCELML and setting my extension to xml.

Although this gets rid of the security warning, even minutes after export is done opening this file in EXCEL causes a "This file is open by another application {Notify, Read only, cancel} options."

Do you have an example that uses this format and an xml extension? All the examples on the demo site use other formats and opening their export causes an excel security warning.



*****4*********

I would like to export a Grid with Hierarchical data (Nested Grids).

The child Grid is a DataTemplate and I am able to access it and export it using examples you have. Examples are using ToHtml and wrapping the output with html Table and styling it.

This is not going to work with ExportML format, so I have to use the ToExcelML function on the nested Grid; problem is getting it nested .... please see a snipet below:

                var grid = sender as RadGridView;

                if (grid != null && grid.HasHierarchy)
                {
                    DataTemplate template = null;
                    template = grid.HierarchyChildTemplate;

                    if (template != null)
                    {
                        var nestedGrid = template.LoadContent() as RadGridView;
                        if (nestedGrid != null)
                        {
                            nestedGrid.DataContext = e.Context;
                            var nestedExport = nestedGrid.ToExcelML(); // Is there a specialized function for nested grids?
                            e.Writer.Write(nestedExport);
                           
                        }
                    }

                }


Thanks for your help!

4 Answers, 1 is accepted

Sort by
0
Sintayehu
Top achievements
Rank 1
answered on 04 Apr 2014, 11:12 PM
If it helps I am on 2013.3.1204.1050 , Silverlight 5 
0
Dimitrina
Telerik team
answered on 09 Apr 2014, 01:58 PM
Hi,

As to the first problem, you can check this article on Microsoft Connect for more info: http://connect.microsoft.com/VisualStudio/feedback/details/690502/savefiledialog-security-warning.

As to your third question, you can check this
Exporting example. I did not observed the same behavior as I exported from this demo with Format: ExcelML.


As to your point 1-2, you can check the same demo. There the export is done though a command on a button click:

<telerik:RadButton Content="Export"
  Command="{Binding ExportCommand, Source={StaticResource context}}"
  CommandParameter="{Binding}"
  Margin="0,10,0,0" />

The ExportAsync method is expected to be slower than the Export method, as it allows asynchronous export of data.

Generally, when exporting hierarchy, I would suggest you to work with the data items as demonstrated on the "Exporting RowDetails" demo. You can specifically check the code inside "ElementExported' event handler.

I hope this helps.

Regards,
Didie
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Sintayehu
Top achievements
Rank 1
answered on 11 Apr 2014, 05:34 PM
Hi Didie,

Thanks for the reply. I am happy with most of your answers and they work as I need them to.

But the example on exportng hierarchy is not a good one. Whether I am loading the hierarchy child template or work with the data items the result will be exporting to html and saving the file as xls. Atleast that is the examples I have found.

**This would mean that when user opens this file the excel security warning of a format mismatch will happen as (format is html and saved as xls).

**Also when exporting to html the filtering will not work.

Do you have an example of exporting hierarchical grid with filtering (not row detail) to ExcelML format with xml extension?

Thanks.
0
Dimitrina
Telerik team
answered on 14 Apr 2014, 03:42 PM
Hello,

The problem with exporting the details with ExcelML is that it does not support nested tables. Therefore, the table with the details (nestedExport) cannot be inserted without errors for invalid content.
If you have the same number of columns in the parent GridView and the details, or less columns in the details, I can suggest you a workaround. Otherwise, you cannot extend our built-in export with ExportFormat.ExcelML like so.

Regards,
Didie
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
GridView
Asked by
Sintayehu
Top achievements
Rank 1
Answers by
Sintayehu
Top achievements
Rank 1
Dimitrina
Telerik team
Share this question
or