export Eror

18 posts, 0 answers
  1. Jamal Husien
    Jamal Husien avatar
    43 posts
    Member since:
    Feb 2010

    Posted 04 Jun 2010 Link to this post

    dear all,
    when i try to export the dataGried to excell i get the following error

    Object reference not set to an instance of an object.


    i made the same as your example on the web.
    the code fail in these line:
        radGridView_searchResult_Co.Export(stream, exportOptions);


    what is the eroor here.

  2. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 07 Jun 2010 Link to this post

    Hi,

    Can you post full exception stack trace?

    Kind regards,
    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.
  3. DevCraft banner
  4. Jonx
    Jonx avatar
    258 posts
    Member since:
    Jul 2012

    Posted 21 Jun 2010 Link to this post

    Hello,
    I have the same problem. I based my code on the online sample. I just added the export code to my existing grid.

     v.2010.1.603.1040 [Installation Folder] [Trial]

    More strangely I only have the problem when I export to csv, the other formats are ok. To make a test I removed what is in the Exporting(object sender, GridViewExportEventArgs e) event...

    It in the call to Export(...

    if (dialog.ShowDialog() == true)
                {
                    using (Stream stream = dialog.OpenFile())
                    {
    GridViewExportOptions exportOptions = new GridViewExportOptions();
    exportOptions.Format = format;
    exportOptions.ShowColumnFooters = true;
    exportOptions.ShowColumnHeaders = true;
    exportOptions.ShowGroupFooters = true;

                        try
                        {
                            grdBeneficiaire.Export(stream, exportOptions);
                        }
                        catch (Exception)
                        {
                            
                            throw;
                        }
                    }
                }

    The stack trace is (it's in french but it means the same) :
    System.NullReferenceException was unhandled by user code
      Message=La référence d'objet n'est pas définie à une instance d'un objet.
      StackTrace:
           à Telerik.Windows.Controls.GridViewExportWriter.RenderDataCells(Object item)
           à Telerik.Windows.Controls.GridViewExportWriter.RenderDataRows(IEnumerable items)
           à Telerik.Windows.Controls.GridViewExportWriter.Render()
           à Telerik.Windows.Controls.GridView.GridViewDataControl.Export(Stream stream, GridViewExportOptions options)
           à MyProduct.SL.Views.Command.btnExport_Click(Object sender, RoutedEventArgs e)
           à System.Windows.Controls.Primitives.ButtonBase.OnClick()
           à System.Windows.Controls.Button.OnClick()
           à System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
           à System.Windows.Controls.Control.OnMouseLeftButtonUp(Control ctrl, EventArgs e)
           à MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName)
      InnerException: 

  5. Yordanka
    Admin
    Yordanka avatar
    634 posts

    Posted 23 Jun 2010 Link to this post

    Hello John,

    Unfortunately, we are not able to get the described error. Could you check the attached project and let us know if we have missed something ? Please feel free to modify the code in order to reproduce the exception and then send it back to us.

    Best wishes,
    Yordanka
    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
  6. Jonx
    Jonx avatar
    258 posts
    Member since:
    Jul 2012

    Posted 23 Jun 2010 Link to this post

    Hum, of course your sample works well ;)

    Also, you made up that sample to make some fun out of me because I'm French??? Hum, not funny!!!

    Ok, am only kidding... One thing that we are sure of, is that we French suck at footbal lately ;)

    So, the thing is that I love the support we are getting here... I did not yet register my componants because I don't have the money but as soon as I get some, I'll do...

    So, sorry I'm a bit verbose, to the point...

    I take some time to give you the answer as it took me a very long time to narrow the thing dow... to the simple thing it is...

    So, in the sample you sent me, just replace your line with this one:
                club.Players.Add(new Player("Nicolas Anelka", 39, Position.FW, null));

    Set Anelka's country to null because he really sucks and is a true null (when he plays in the Equipe de France of course), this will make your sample crash for csv export... at least it does for me... and me know if this works for you...

    And thanks for the excellent support, I have plenty of questiosn to go ;)

    ps: I did not test if the sample works with null but with another football player ;)
  7. Yordanka
    Admin
    Yordanka avatar
    634 posts

    Posted 24 Jun 2010 Link to this post

    Hi John,

    However my inappropriate application we have good news :). If you upgrade to our latest internal build (version 618) you will get the problem fixed. Please, give it a try and let us know how it goes.

    Sincerely yours,
    Yordanka
    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
  8. Jonx
    Jonx avatar
    258 posts
    Member since:
    Jul 2012

    Posted 24 Jun 2010 Link to this post

    Yes, I confirm, fixed...
    Thank you for your help and good luc for your team. It can't be worse then for France ;)
  9. zhu
    zhu avatar
    20 posts
    Member since:
    Oct 2010

    Posted 12 Nov 2010 Link to this post

    I also have this question.My version is 2010.2.924.1040
  10. zhu
    zhu avatar
    20 posts
    Member since:
    Oct 2010

    Posted 12 Nov 2010 Link to this post

    Some can export,Some can't  export.I don't know why.
  11. zhu
    zhu avatar
    20 posts
    Member since:
    Oct 2010

    Posted 12 Nov 2010 Link to this post

    if you have solution. please send email to me.

    My email is zhuzongsheng@beyondsoft.com.

    Thanks very much.
  12. Jonx
    Jonx avatar
    258 posts
    Member since:
    Jul 2012

    Posted 12 Nov 2010 Link to this post

    Dear zhu,
    This is a help forum. Nobody will send you a solution by email.

    You need to be more specific to get help.
    What is your exact problem. What is the error message you get.
    Eventually, can you share a working sample that will expose the problem?
    That way rest assured that the people here will help you very fast.

    Please read the following blog post. It may help you idetify your problem or at least ask help in a better way:
    http://blogs.telerik.com/blogs/posts/10-09-29/isolating_a_problem_in_a_sample_project.aspx

    Now, as a wild guess as for you export problem... Are you exporting unicode text?
    For exemple I am exporting french text with accents and this made the export crash...

    Good luck with that,
    John. 
  13. zhu
    zhu avatar
    20 posts
    Member since:
    Oct 2010

    Posted 14 Nov 2010 Link to this post

    SaveFileDialog dialog = new SaveFileDialog()
     {
                        Filter = "xls files (*.xls)|*.xls|All files (*.*)|*.*"
     };
     if (dialog.ShowDialog() == true)
    {
       using (Stream stream = dialog.OpenFile())
        {
           using (StreamWriter writer =
            new StreamWriter(stream, Encoding.UTF8))
             {
                 //writer.Write(statisticDataGrid.ToExcelML());
                                writer.Write(statisticDataGrid.ToHtml());
               }
                stream.Close();
       }
    }

    I using Encoding.UTF8
  14. zhu
    zhu avatar
    20 posts
    Member since:
    Oct 2010

    Posted 14 Nov 2010 Link to this post

    I don't know why. Some is Ok. Some is wrong.
  15. Jonx
    Jonx avatar
    258 posts
    Member since:
    Jul 2012

    Posted 14 Nov 2010 Link to this post

    Your code does not help to reproduce the problem.

    I'm pretty sre it is related to the data you try to save.

    Maybe you can add a try catch around the line writer.Write(statisticDataGrid.ToHtml()); ?
    That way you will be able to spot what line makes the thing crash and what is inside it.

    Maybe you have some null values...
  16. zhu
    zhu avatar
    20 posts
    Member since:
    Oct 2010

    Posted 14 Nov 2010 Link to this post

    there is null value. but I replace with ''. there is still error
  17. Jonx
    Jonx avatar
    258 posts
    Member since:
    Jul 2012

    Posted 15 Nov 2010 Link to this post

    Like I said, post a working sample that will let the people here reproduce the error...
  18. zhu
    zhu avatar
    20 posts
    Member since:
    Oct 2010

    Posted 15 Nov 2010 Link to this post

    Thanks John,I find the cause.There is column like this:Account  Number.there is blank space in column
  19. Jonx
    Jonx avatar
    258 posts
    Member since:
    Jul 2012

    Posted 16 Nov 2010 Link to this post

    Great, good news...
Back to Top
DevCraft banner