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

6 posts, 0 answers
  1. Paul
    Paul avatar
    7 posts
    Member since:
    Feb 2015

    Posted 04 Jun 2015 Link to this post

    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

  2. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 09 Jun 2015 Link to this post

    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
  3. Paul
    Paul avatar
    7 posts
    Member since:
    Feb 2015

    Posted 09 Jun 2015 in reply to Maya Link to this post

    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>();
            }

  4. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 09 Jun 2015 Link to this post

    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
  5. Paul
    Paul avatar
    7 posts
    Member since:
    Feb 2015

    Posted 09 Jun 2015 in reply to Maya Link to this post

    v2013.1.422.45
  6. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 09 Jun 2015 Link to this post

    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
Back to Top