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

ToExcelML throwing Specified cast is not valid.

3 Answers 71 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Fransiscus Setiawan
Top achievements
Rank 1
Fransiscus Setiawan asked on 25 May 2010, 03:51 AM
Hi,

I've got a problem with ToExcelML() extension method for RadGridView, I tried the other method of ToCSV which is working fine.

Code Behind
   Dim dialog As New SaveFileDialog() With {.Filter = "EXCEL files (*.xls)|*.xls|All files (*.*)|*.*"
        If dialog.ShowDialog() = True Then 
            Using stream As Stream = dialog.OpenFile() 
                Using writer As New StreamWriter(stream, Encoding.UTF8) 
                    writer.Write(dgResults.ToExcelML()) 
                End Using 
                stream.Close() 
            End Using 
        End If 

    Private Sub ExportResults_Exporting(ByVal sender As ObjectByVal e As Telerik.Windows.Controls.GridViewExportEventArgs) Handles dgResults.Exporting 
        'Change the font size and the background color of the table header only 
        If (e.Element = ExportElement.HeaderRow Or e.Element = ExportElement.HeaderCell) Then 
            e.FontSize = e.FontSize + 4 
            e.Background = Colors.DarkGray 
 
            'Change the font size and the background color of the group headers only 
        ElseIf (e.Element = ExportElement.GroupHeaderCell Or e.Element = ExportElement.GroupHeaderRow) Then 
            e.FontSize = e.FontSize + 2 
            e.Background = Colors.LightGray 
        End If 
    End Sub 

XAML

      <telerikGrid:RadGridView x:Name="dgResults" Canvas.Left="-1500" Grid.Row="1"  
                Grid.Column="0" AutoGenerateColumns="False" Exporting="ExportResults_Exporting" CanUserFreezeColumns="False"></telerikGrid:RadGridView> 
   

The column definition is being generated on the fly inside the async_completed of WCF.

The error that I'm getting is "Specified cast is not valid".

3 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 25 May 2010, 07:32 AM
Hello,

Can you post more info about your grid version?

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
Fransiscus Setiawan
Top achievements
Rank 1
answered on 25 May 2010, 07:38 AM
Hi, This is the assembly version of RadGridView.dll

2009.3.1314.1030
0
Accepted
Vlad
Telerik team
answered on 25 May 2010, 07:57 AM
Hi,

This is our Q3 2009 Sp1 - can you try our latest official version (Q1 2010 SP1) instead?

Best wishes,
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.
Tags
GridView
Asked by
Fransiscus Setiawan
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Fransiscus Setiawan
Top achievements
Rank 1
Share this question
or