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

Excelexport with Gridlookupcolumns

8 Answers 63 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Per Holmqvist
Top achievements
Rank 2
Per Holmqvist asked on 18 Jan 2009, 11:08 PM
If I have a gridview and want to export it to excel it does export all values correct.
But if I have a column that is a lookup I get the ID and not the displayed value of the lookuptable value.
Where do I set that settings for my export?

My exportfunction from your VB examples
    Private Sub ExportToExcel(ByVal ExportAsML As BooleanByVal Exportfor2007 As BooleanOptional ByVal exportVisual As Boolean = True)  
        If ExportAsML = False AndAlso saveFileDialog.ShowDialog() = System.Windows.Forms.DialogResult.OK Then 
            'Export To Excel  
            If (Not saveFileDialog.FileName.Equals(String.Empty)) Then 
                Dim file As New FileInfo(saveFileDialog.FileName)  
                If file.Extension.Equals(".xls"Then 
                    'Här skall det bli ändring till gamla Excel  
                    '  Export(saveFileDialog.FileName)  
                Else 
                    MessageBox.Show("Felaktig filtyp")  
                End If 
            Else 
                MessageBox.Show("Välj ett filnamn.")  
            End If 
        ElseIf ExportAsML = True AndAlso saveFileDialog.ShowDialog() = System.Windows.Forms.DialogResult.OK Then 
            'Export To ExcelML  
            If (Not saveFileDialog.FileName.Equals(String.Empty)) Then 
                Dim fileName As String = Me.saveFileDialog.FileName  
                Dim exporter As New ExportToExcelML()  
                If Exportfor2007 Then 
                    exporter.RunExport(Me.RadGridView1, fileName, ExportToExcelML.ExcelMaxRows._1048576, exportVisual)  
                Else 
                    exporter.RunExport(Me.RadGridView1, fileName, ExportToExcelML.ExcelMaxRows._65536, exportVisual)  
                End If 
                MessageBox.Show("Export klar.")  
            Else 
                MessageBox.Show("Välj ett filnamn.")  
            End If 
        End If 
    End Sub 
 

8 Answers, 1 is accepted

Sort by
0
Martin Vasilev
Telerik team
answered on 20 Jan 2009, 02:20 PM
Hello Per Holmqvist,

Thank you for writing.

I confirm the behavior. We will extend exporting functionality to export DisplayMember in some future release. Unfortunately, I cannot give you a suitable work-around currently. I have updated your Telerik points for bringing our attention to this.

If you have other questions, do not hesitate to contact me again.

Sincerely yours,
Martin Vasilev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Phil
Top achievements
Rank 1
answered on 27 Mar 2009, 07:46 PM
Hello Per Holmqvist,

DId you find a work around?  How did you solve this obvious weakness?
0
Martin Vasilev
Telerik team
answered on 30 Mar 2009, 02:52 PM
Hello Phil,

Thank you for the question.

I am glad to inform you, that we have already changed this, and in the latest release Q1 2009 the ExportToExcelML class exports DisplayMember in the excel file. Please, download the latest version and give it a try.

Sincerely yours,
Martin Vasilev
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
Per Holmqvist
Top achievements
Rank 2
answered on 31 Mar 2009, 03:27 PM
I can't confirm this.
I just updated my projekt, using the 2009.1.9.316 version.

Using the following code
Dim fileName As String = Me.saveFileDialog.FileName  
Dim exporter As New ExportToExcelML()  
exporter.RunExport(Me.RadGridView1, fileName, ExportToExcelML.ExcelMaxRows._1048576, true) 

But I still dont get the DisplayMember in the excel file...
0
Martin Vasilev
Telerik team
answered on 01 Apr 2009, 10:23 AM
Hello Per Holmqvist,

Thank you for contacting us.

Currently, this feature works only for the GridViewComboBox column and correct assigned Value and Display members. Please, change your GridViewLookUpColumn with GridViewComboBox and try again. Since the combo inherits the lookup column, this swap will not bring any differences in your functionality. Meanwhile, we will add exporting display member for the lookup column in the upcoming Q1 2008 Service Pack 1 release. 

Write me back if you need additional assistance.

Kind regards,
Martin Vasilev
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
Per Holmqvist
Top achievements
Rank 2
answered on 01 Apr 2009, 01:01 PM
Thanks.

I tried to replace all GridViewLookUpColumn with GridViewComboBox but get errors that it is not defined.

 

Dim GridViewComboBox1 As Telerik.WinControls.UI.GridViewComboBox = New Telerik.WinControls.UI.GridViewComboBox

There are GridViewComboBoxColumn, is this what you mean?
i changed to that and it seams to work as expected.
Is there any problem with exporting datefields?
My GridViewDateTimeColumn don't get formatted as datetime in Excel but a numeric...

 

0
Martin Vasilev
Telerik team
answered on 02 Apr 2009, 03:57 PM
Hi Per Holmqvist,

Thank you for getting back to me.

Please accept my appologies for the spelling mistake. Actually, I meant GridViewComboBoxColumn (but not GridViewComboBox).

Concerning the DateTime format, I suggest you to define an export format for your DateTime column:
 
radGridView1.Columns["myDateTimeColumn"].ExcelExportType = DisplayFormatType.GeneralDate 

Sincerely yours,
Martin Vasilev
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
Thomas Ossowski
Top achievements
Rank 1
answered on 15 Feb 2010, 01:34 PM

Tags
GridView
Asked by
Per Holmqvist
Top achievements
Rank 2
Answers by
Martin Vasilev
Telerik team
Phil
Top achievements
Rank 1
Per Holmqvist
Top achievements
Rank 2
Thomas Ossowski
Top achievements
Rank 1
Share this question
or