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

GridViewDataControlExport(Stream stream, GridViewExportOptions options) Exception: Object reference not set to an instance of an object

5 Answers 89 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 04 Jun 2015, 11:45 AM

Before export to Excel we add aggregate function:

var sumFunction = new CountFunction()
{
ResultFormatString = " ({0} items): "
};
column.AggregateFunctions.Add(sumFunction);

Export functionality:

var options = new GridViewExportOptions
{
Format = ExportFormat.ExcelML,
ShowColumnHeaders = true,
ShowColumnFooters = true,
ShowGroupFooters = true,
Encoding = Encoding.UTF8
};

var fileToExportTo = exportFileInfo.FullName;
using (FileStream fs = new FileStream(fileToExportTo, FileMode.OpenOrCreate))
{
gridControl.Export(fs, options);
}

Exception: Object reference not set to an instance of an object.

   at Telerik.Windows.Controls.GridViewBoundColumnBase.<>c__DisplayClass18.<Telerik.Windows.Controls.IExportableColumn.GetCellContent>b__12(AggregateFunction f) in c:\TB\221\WPF_Scrum\Current_HotFix\Sources\Controls\GridView\GridView\GridView\Columns\GridViewBoundColumnBase.cs:line 55
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at Telerik.Windows.Controls.GridViewBoundColumnBase.Telerik.Windows.Controls.IExportableColumn.GetCellContent(Object parameter) in c:\TB\221\WPF_Scrum\Current_HotFix\Sources\Controls\GridView\GridView\GridView\Columns\GridViewBoundColumnBase.cs:line 56
   at Telerik.Windows.Controls.GridViewExportWriter.RenderHeaderOrFooterCells(ExportElement element, Object context) in c:\TB\221\WPF_Scrum\Current_HotFix\Sources\Controls\GridView\GridView\GridView\Exporting\GridViewExportWriter.cs:line 692
   at Telerik.Windows.Controls.GridViewExportWriter.RenderFooterRow() in c:\TB\221\WPF_Scrum\Current_HotFix\Sources\Controls\GridView\GridView\GridView\Exporting\GridViewExportWriter.cs:line 535
   at Telerik.Windows.Controls.GridViewExportWriter.Render() in c:\TB\221\WPF_Scrum\Current_HotFix\Sources\Controls\GridView\GridView\GridView\Exporting\GridViewExportWriter.cs:line 101
   at Telerik.Windows.Controls.GridView.GridViewDataControl.Export(Stream stream, GridViewExportOptions options) in c:\TB\221\WPF_Scrum\Current_HotFix\Sources\Controls\GridView\GridView\GridView\Exporting\GridViewDataControl.Exporting.cs:line 31

5 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 09 Jun 2015, 08:03 AM
Hello Paul,

I tried to reproduce the issue you reported, but without any success. Could you run through the project attached and let me know whether I am missing anything ? 

Regards,
Maya
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Paul
Top achievements
Rank 1
answered on 09 Jun 2015, 11:06 AM

Thank you for your answer.

So ... If you you remove the data of the grid (the grid will be empty) you will get the Exception.

 

public static ObservableCollection<Club> GetClubs()
        {
            return new ObservableCollection<Club>();
        }

0
Maya
Telerik team
answered on 09 Jun 2015, 11:17 AM
Hello Paul,

I tried the same functionality with empty grid, but I am still not able to reproduce the exception. Which version are you working with ? If it is not the current official one (Q1 2015 SP1), could you try with it ? 

Regards,
Maya
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Paul
Top achievements
Rank 1
answered on 09 Jun 2015, 11:32 AM
v2013.1.422.45
0
Maya
Telerik team
answered on 09 Jun 2015, 01:13 PM
Hi Paul,

Actually, this version is from around 2 years ago and unfortunately, even if there is an exception in the code, there is no much that we can do.  My recommendation is to download our current official version and give it a try instead.

Regards,
Maya
Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
GridView
Asked by
Paul
Top achievements
Rank 1
Answers by
Maya
Telerik team
Paul
Top achievements
Rank 1
Share this question
or