RadGridView export to Excel creates empty file

3 posts, 1 answers
  1. Niraj
    Niraj avatar
    4 posts
    Member since:
    Oct 2015

    Posted 25 Feb 2016 Link to this post

    <t:RadGridView x:Name="Logs">
           <t:GridViewDataColumn CellTemplateSelector="{StaticResource IconTemplateSelector}" />
           <t:GridViewDataColumn DataMemberBinding="{Binding LogLevel,Mode=OneWay}" Header="Level"
                            CellStyle="{StaticResource PaddedCell}"/>                
           <t:GridViewDataColumn DataMemberBinding="{Binding LogID,Mode=OneWay}" 
           <t:GridViewDataColumn DataMemberBinding="{Binding MachineDateTime,Mode=OneWay}"
                            Header="Machine Time"
                            CellStyle="{StaticResource PaddedCell}"/>
           <t:GridViewDataColumn DataMemberBinding="{Binding Occured, Mode=OneWay}"
                            CellStyleSelector="{StaticResource ColorSelector}"/>
           <t:GridViewDataColumn DataMemberBinding="{Binding System,Mode=OneWay}"
                            CellStyle="{StaticResource PaddedCell}" />
           <t:GridViewDataColumn DataMemberBinding="{Binding Mode,Mode=OneWay}"
                            CellStyle="{StaticResource PaddedCell}" />
           <t:GridViewDataColumn DataMemberBinding="{Binding CallingClass,Mode=OneWay}"
                            Header="Calling Class"
                            CellStyle="{StaticResource PaddedCell}" />
           <t:GridViewDataColumn DataMemberBinding="{Binding Message,Mode=OneWay}"
                            CellStyle="{StaticResource PaddedCell}" />
           <t:GridViewDataColumn DataMemberBinding="{Binding Exception,Mode=OneWay}"
                            CellStyle="{StaticResource PaddedCell}" /> 


    I have above data-bound RadGridView (named Logs) and I am trying to export its contents, but it always results into an empty exported file.

    And I try to export the contents of RadGridView with below code:

    private void ExportLogs()
        using (var stream = File.Create(filepath))
                     new GridViewExportOptions()
                         Format = ExportFormat.ExcelML,
                         ShowColumnHeaders = true,
                         ShowColumnFooters = false,
                         ShowGroupFooters = false,

    No exceptions or warning received.
    Any help would be appreciated. Thank you.
  2. Answer
    Dilyan Traykov
    Dilyan Traykov avatar
    1073 posts

    Posted 01 Mar 2016 Link to this post

    Hello Niraj,

    I have created a sample project as showed in the Export article of our documentation, which successfully exports its content in a .xls file in a given directory.

    Could you please have a look at it and see how it differs from your approach?
    Could you also confirm that .xls is set as the file extension for the newly-created file?

    Should the issue persist, could you please provide a sample project for me to examine so that I can further assist you with your case?

    Dilyan Traykov
    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 Feedback Portal and vote to affect the priority of the items
  3. Niraj
    Niraj avatar
    4 posts
    Member since:
    Oct 2015

    Posted 10 Mar 2016 in reply to Dilyan Traykov Link to this post

    Dear Dilyan,

    Thank you for the sample code and sorry for coming back late as I didn't had a chance to test your code.

    The problem with my code was that due to threading the GridView as accessed from non-UI thread, which lead contents of GridView to be in non-accessible state. Then I tried to call the Export function from UI thread and it worked as expected.

    Again thank you very much for your quick response, I really appreciate it.


Back to Top