This is a migrated thread and some comments may be shown as answers.
export Eror
17 Answers 94 Views
This is a migrated thread and some comments may be shown as answers.
Jamal Husien
Top achievements
Rank 1
Jamal Husien asked on 04 Jun 2010, 10:11 PM
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.

17 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 07 Jun 2010, 06:19 AM
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.
0
Jonx
Top achievements
Rank 2
answered on 21 Jun 2010, 03:59 PM
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: 

0
Yordanka
Telerik team
answered on 23 Jun 2010, 09:13 AM
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
0
Jonx
Top achievements
Rank 2
answered on 23 Jun 2010, 10:55 PM
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 ;)
0
Yordanka
Telerik team
answered on 24 Jun 2010, 08:32 AM
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
0
Jonx
Top achievements
Rank 2
answered on 24 Jun 2010, 10:50 AM
Yes, I confirm, fixed...
Thank you for your help and good luc for your team. It can't be worse then for France ;)
0
zhu
Top achievements
Rank 1
answered on 12 Nov 2010, 10:54 AM
I also have this question.My version is 2010.2.924.1040
0
zhu
Top achievements
Rank 1
answered on 12 Nov 2010, 10:56 AM
Some can export,Some can't  export.I don't know why.
0
zhu
Top achievements
Rank 1
answered on 12 Nov 2010, 10:58 AM
if you have solution. please send email to me.

My email is zhuzongsheng@beyondsoft.com.

Thanks very much.
0
Jonx
Top achievements
Rank 2
answered on 12 Nov 2010, 04:54 PM
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. 
0
zhu
Top achievements
Rank 1
answered on 15 Nov 2010, 02:18 AM
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
0
zhu
Top achievements
Rank 1
answered on 15 Nov 2010, 02:26 AM
I don't know why. Some is Ok. Some is wrong.
0
Jonx
Top achievements
Rank 2
answered on 15 Nov 2010, 02:44 AM
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...
0
zhu
Top achievements
Rank 1
answered on 15 Nov 2010, 03:09 AM
there is null value. but I replace with ''. there is still error
0
Jonx
Top achievements
Rank 2
answered on 15 Nov 2010, 11:17 AM
Like I said, post a working sample that will let the people here reproduce the error...
0
zhu
Top achievements
Rank 1
answered on 16 Nov 2010, 04:30 AM
Thanks John,I find the cause.There is column like this:Account  Number.there is blank space in column
0
Jonx
Top achievements
Rank 2
answered on 16 Nov 2010, 11:04 AM
Great, good news...
Asked by
Jamal Husien
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Jonx
Top achievements
Rank 2
Yordanka
Telerik team
zhu
Top achievements
Rank 1
Share this question
or