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

[Solved] Export Bug With ShowColumnFooters

10 Answers 227 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Lee
Top achievements
Rank 1
Lee asked on 08 Jun 2010, 02:38 PM
I'm currently trying to use the Export functionality on the RadGridView and ran into a possible bug when exporting to the HTML format.

I've place a button on my application to initiate the Export as follows:
private void tonnageByArrivalExportButton_Click(object sender, RoutedEventArgs e) 
{ 
    string extension = "xls"; 
    SaveFileDialog dialog = new SaveFileDialog() 
    { 
        DefaultExt = extension, 
        Filter = String.Format("{1} files (*.{0})|*.{0}|All files (*.*)|*.*", extension, "Excel"), 
        FilterIndex = 1 
    }; 
    if (dialog.ShowDialog() == true) 
    { 
        try 
        { 
            using (Stream stream = dialog.OpenFile()) 
            { 
                GridViewExportOptions exportOptions = new GridViewExportOptions(); 
                exportOptions.Format = ExportFormat.Html; 
                exportOptions.ShowColumnHeaders = true; 
                exportOptions.ShowColumnFooters = true; 
                exportOptions.ShowGroupFooters = false; 
 
                tonnageByArrivalTable.Export(stream, exportOptions); 
            } 
        } 
        catch (IOException) 
        { 
            // File in use 
        } 
        catch 
        { 
          // Another exception type 
        } 
    } 
} 
 

But if my grid does not define column footers for every column, and in my case I'm only defining one for one column, I'm getting an exception when I call the tonnageByArrivaleTable.Export(stream, exportOptions).  The exception is 
"System.NullReferenceException was caught
  Message=Object reference not set to an instance of an object.
  StackTrace:
       at Telerik.Windows.Controls.GridViewExportWriter.RenderHeaderOrFooterCells(ExportElement element, Object value)
       at Telerik.Windows.Controls.GridViewExportWriter.RenderFooterRow()
       at Telerik.Windows.Controls.GridViewExportWriter.Render()
       at Telerik.Windows.Controls.GridView.GridViewDataControl.Export(Stream stream, GridViewExportOptions options)
       at CAXDock_RiaServices.DockDash.tonnageByArrivalExportButton_Click(Object sender, RoutedEventArgs e)
  InnerException: "

The resulting export file is only containing a portion of the export results cut off in mid stream.

Either setting the exportOptions.ShowColumnFooters = false, changing export format to something other than HTML, or by defining column footers for each column (which I don't want to do) and the exception goes away and the export completes properly.

Any ideas?

10 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 08 Jun 2010, 02:46 PM
Hi,

 Do you have our latest service pack (Q1 2010 SP2)? 

Sincerely yours,
Vlad
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
Lee
Top achievements
Rank 1
answered on 08 Jun 2010, 02:50 PM
I've downloaded it but have not installed it yet.  I'm in the process of putting the finishing touches on an application that needs to be rolled out to my customer by weeks end and I didn't want to risk upgrading at this point.  I'm currently running Silverlight 4 and Telerik's Q1 2010 SP1.

Is it fixed in SP2?  I didn't see that as a fixed item.
0
Yavor Georgiev
Telerik team
answered on 10 Jun 2010, 09:19 AM
Hello Lee Weisenberger,

 It has been fixed in our internal builds since before our SP2 release. You can install our SP2 release alongside the SP1 release. Different RadControls versions can live side by side. The binaries are stored in separate folders in your Telerik RadControls installation folder (C:\Program Files\Telerik), so there's no danger to your current project.

I can recommend installing our SP2 release and testing the functionality in a separate test project referencing the SP2 controls.

Best wishes,
Yavor Georgiev
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
Lee
Top achievements
Rank 1
answered on 10 Jun 2010, 01:01 PM
Thanks.  I upgraded to Q1 2010 SP2 and the exception went away, however I'm not sure about the results I got.

I only specify aggregate functions for two of the middle columns in my table, which show up fine on the grid, but when I export the table, I end up with extra data in the footer for the last column, which is the same as the footer data from the previous column.

Here is my grid definition:
<telerikGridView:RadGridView Name="tonnageByPlantTable" 
                             Exporting="tonnageByPlantTable_Exporting" 
                             AutoExpandGroups="True" 
                             IsFilteringAllowed="False" 
                             ShowGroupFooters="True" ShowColumnHeaders="True" ShowGroupPanel="False" RowIndicatorVisibility="Collapsed" 
                             AutoGenerateColumns="False" 
                             EnableRowVirtualization="True" 
                             Grid.Row="2"> 
    <telerikGridView:RadGridView.GroupDescriptors> 
        <telerikData:GroupDescriptor Member="Group" > 
        </telerikData:GroupDescriptor> 
    </telerikGridView:RadGridView.GroupDescriptors> 
    <telerikGridView:RadGridView.Columns> 
        <telerikGridView:GridViewDataColumn Header="Ship To" HeaderTextAlignment="Center" UniqueName="ShipTo" TextAlignment="Left" IsReadOnly="True" MinWidth="50"  > 
        </telerikGridView:GridViewDataColumn> 
         
        <telerikGridView:GridViewDataColumn Header="Packing Slip Count" HeaderTextAlignment="Center" UniqueName="PackingSlipCount" TextAlignment="Left" IsReadOnly="True" MinWidth="50"  > 
            <telerikGridView:GridViewColumn.AggregateFunctions> 
                <telerikData:SumFunction Caption="# Packing Slips: " /> 
            </telerikGridView:GridViewColumn.AggregateFunctions> 
 
        </telerikGridView:GridViewDataColumn> 
        <telerikGridView:GridViewDataColumn Header="Total Weight" HeaderTextAlignment="Center" UniqueName="CalcGrossWeight" TextAlignment="Center" IsReadOnly="True" MinWidth="50" DataFormatString="{}{0:F} lbs"> 
            <telerikGridView:GridViewColumn.AggregateFunctions> 
                <telerikData:SumFunction Caption="Total Weight: "/> 
            </telerikGridView:GridViewColumn.AggregateFunctions> 
        </telerikGridView:GridViewDataColumn> 
        <telerikGridView:GridViewDataColumn Header="Group" HeaderTextAlignment="Center" UniqueName="Group" TextAlignment="Center" IsReadOnly="True" MinWidth="50"   > 
        </telerikGridView:GridViewDataColumn> 
    </telerikGridView:RadGridView.Columns> 
 
</telerikGridView:RadGridView> 
 

I've also uploaded two screen shots.  One two show what the RadGrid looks like, which is correct, and one that shows the Excel export, which appears with the incorrect last column footer.

Am I doing something wrong?
0
Yavor Georgiev
Telerik team
answered on 10 Jun 2010, 01:23 PM
Hello Lee Weisenberger,

 This is a known issue and has been recently fixed. The fix will be available in our imminent Q2 Beta release, and also the weekly internal build published each Friday, which you can download from your account. The fix will be in tomorrow's internal build.

Kind regards,
Yavor Georgiev
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
Pic Micro
Top achievements
Rank 1
answered on 06 Aug 2010, 10:14 PM
Hello, I followed the example provided in the first post of this thread with the exception of exportOptions.ShowGroupFooters = true   but the exported excel shows weird data in all the cells of the corresponding row where the group footer info should be. It seems like an object dump.

This is the kind of data I'm getting in every cell in excel:
"[QCVG: Key=item 0; ItemCount=1; HasSubgroups=False; ParentGroup=[QCVG: Key=Root; ItemCount=10; HasSubgroups=True; "

What could be the problem?

Thx

0
Vlad
Telerik team
answered on 09 Aug 2010, 06:58 AM
Hello,

 Group footers will not be exported by default - you need to catch ElementExporting event and provide value similar to this demo. 

Greetings,
Vlad
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
Pic Micro
Top achievements
Rank 1
answered on 09 Aug 2010, 07:46 PM
Thanks the example you provided has everything i needed to know.
0
Dan Kane
Top achievements
Rank 1
answered on 03 Oct 2010, 10:43 PM
Hi,
I am having an issue where if I set ShowGroupFooters = true on the GridViewExportOptions the Group Header information is no longer generated. If I set it to false, then I get the GroupHeaderRow and GroupHeaderCells generated in the ElementExporting event. I want both the Headers and the Footers so this is quite frustrating. I am using identical export code as in your demo, but can see that the demo generates both the Group Headers and Footers when exporting so not sure where I am going wrong.

Any ideas?

[Edit]
Sorry I should amend this; the issue is not to do with whether ShowGroupFooters is true or false, I have instead discovered that the Group Headers are only exported if the ExportFormat is Html.

Is there any reason for this?
0
Vlad
Telerik team
answered on 07 Oct 2010, 08:54 AM
Hello Dan,

 Indeed currently this is implemented only for HTML export. We will do our best to provide this for ExcelML as soon as possible.

Best wishes,
Vlad
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
Tags
GridView
Asked by
Lee
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Lee
Top achievements
Rank 1
Yavor Georgiev
Telerik team
Pic Micro
Top achievements
Rank 1
Dan Kane
Top achievements
Rank 1
Share this question
or