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

[Solved] ToExcelML() Null Reference

9 Answers 201 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.
om
Top achievements
Rank 1
om asked on 27 Aug 2009, 04:17 PM
Hi,

I have a rad grid, which is bound with a collection of object. When I use e.g. string output = radgrid.ToHtml(); it works all fine but when I try to use 

string output = radgrid.ToExcelML() it throws a Null Reference Exception and doesn not generate any result at all.

Is there any special way to use radgrid.ToExcelIML() ?

9 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 31 Aug 2009, 05:45 AM
Hello om,

Can you send us a bit more info about this exception? You can check this demo where ExcelML export works fine:
http://demos.telerik.com/silverlight/#GridView/Exporting

Kind regards,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
om
Top achievements
Rank 1
answered on 01 Sep 2009, 06:08 PM
Hi Vlad,

I infact followed the steps mentioned in Demo. What I am thinking is or suspicious about is the version of my grid, which is:

Version 2009.2.710.1020
RuntimeVersion: V2.0.50727

Can you please confirm it for me please.

Thanks.
0
om
Top achievements
Rank 1
answered on 03 Sep 2009, 04:15 PM
Hi Vlad,

In my previous post, I mentioned the version of grid I am using. If that was not enough then following is the code which I am using:

//Code in xaml  
<RadGrid:RadGridView x:Name="radResult" Grid.Row="1" Grid.Column="0" ShowGroupPanel="False" CanUserResizeColumns="True" CanUserReorderColumns="True" AutoGenerateColumns="False" ItemsSource="{Binding Path=Result.Items, Mode=TwoWay}"></RadGrid:RadGridView> 
 
//Code in .cs  
string content = string.Empty;  
content = radResult.ToExcelML(); <- This method call throws null reference error 

By the way, export to excel doesn't work on your demo site anymore, or didn't work for me atleast. the popup came with error "Un-authorized access". I remember it used to work, but that was before SL3 was released.

I have two suspisions now,
1) This bug is happening may be because, it was developed on SL2 platform, because I am using SL3.
2) The version of the grid I have is not correct.

I will, highly appriciate your attention towards this issue, its been few days now that i am trying to sortout this problem.
0
Vlad
Telerik team
answered on 04 Sep 2009, 12:19 PM
Hi om,

We tried to reproduce both issues however without success. The only issue we can confirm for now with ToExcelML() indeed Null Reference exception however with GridViewDropDownColumn with IValueConverter - this issue was fixed and the fix will be available latest today with our latest internal build.

The only option I can suggest you is to send us small project where we can reproduce the exception at your end.

All the best,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
om
Top achievements
Rank 1
answered on 05 Oct 2009, 08:44 PM
Hi Vlad,

I finally found out where that error was comming from. It was happening when; let say. If were to bind a column with wrong binding name, this would lead the grid to show nothing in that perticular column where binding property for column was wrong.

I caught this issue, when I observed that I had binding error being thrown in output window through Grid. It was almost two weeks ago.

Now, out of no where, I am getting the similar error:

A first chance exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll

Application_UnhandledException:

System.NullReferenceException: Object reference not set to an instance of an object.

at Telerik.Windows.Data.TypeExtensions.IsNullableType(Type type)

at Telerik.Windows.Data.TypeExtensions.GetNonNullableType(Type type)

at Telerik.Windows.Data.TypeExtensions.GetNumericTypeKind(Type type)

at Telerik.Windows.Data.TypeExtensions.IsNumericType(Type type)

at Telerik.Windows.Controls.ExportExtensions.GetExcelMLType(Type type)

at Telerik.Windows.Controls.ExportExtensions.GetRowValues(GridViewDataControl source, IList`1 records, StringBuilder& builder, ExportFormat format)

at Telerik.Windows.Controls.ExportExtensions.ToExcelML(GridViewDataControl source, IList`1 records, Boolean includeHeader)

at SolutionQ.Eclipse.Silverlight.Content.Search.ReportResult.Tabs.tabResult.ExportToExcel()

at SolutionQ.Eclipse.Silverlight.Content.Search.ReportResult.Tabs.tabResult.<RadMenuItem_Click>b__2()

This time, I don't see any binding errors being thrown by Telerik Grid. the only error is being thrown is mentioned above at the time of ExporToIML.

There is no trace at all except this, no trace in event viewer. Nothing!!! So, I don't really know, how to drill down into this error any further.

Do you have any recomendation or Idea that how I can get to the source of this error? I have a feeling that this must be because of some property having invalid value or null value, but which one would it be.. its ofcourse not from those properties which are bound to columns. because all of them have values.

I am sorry, that I can't really send you the copy of my project because, its too big and the objects I am using are are extreemly complicated with 5 level of inheritence. So, would take really long only  to create a dummny project and try to reproduce this problem over there, which could be then sent to you.

Thanks
OM

0
om
Top achievements
Rank 1
answered on 05 Oct 2009, 08:46 PM
By the way Vlad, can you give me some kind of pointer that what kind of properties of bound object, Telerik Grid try to access while exporting to IML format? That will for sure give me some kind of clue. I am hoping that I doesn't try to access all the properties of the object in question except what are bound to columns?

Thanks
0
Vlad
Telerik team
answered on 06 Oct 2009, 08:04 AM
Hi om,

Can you please check what will be the situation with our latest build? I've checked this method (GetExcelMLType) and I've noticed that now there is a != null check.

Let me know how it goes.

Sincerely yours,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
om
Top achievements
Rank 1
answered on 06 Oct 2009, 01:52 PM
Thanks alot for such a quick reply Vlad. I will be giving it a try today!
0
Ryan Morgan
Top achievements
Rank 1
answered on 07 Oct 2009, 05:58 AM
http://www.telerik.com/community/forums/silverlight/gridview/excelml-null-reference-caused-by-invalid-binding-from-uniquename.aspx

Check out this thread - do you have a uniquename with no data binding? Does it work with toCsv or ToHtml?

Ryan Morgan
www.ArrowDesigns.com
Tags
GridView
Asked by
om
Top achievements
Rank 1
Answers by
Vlad
Telerik team
om
Top achievements
Rank 1
Ryan Morgan
Top achievements
Rank 1
Share this question
or