RadGridView ToHtml() results missing column data

2 posts, 0 answers
  1. Mark
    Mark avatar
    13 posts
    Member since:
    Aug 2012

    Posted 21 Mar 2012 Link to this post

    I am creating an exported Excel file from a RadGRidView via the ToHtml() method. However, some of the columns are missing data. Below is an example of two columns from the grid. The first (Description) results in valid data. The second (Coupon) has no data in the resultant Excel column:

                            <telerikGV:GridViewDataColumn UniqueName="Description"    IsReadOnly="True" Header="Description" Width="200">
                                <telerikGV:GridViewColumn.CellTemplate>
                                    <DataTemplate>
                                        <Grid>
                                            <uc1:NextFocusTextBox Text="{Binding Path=Description}" IsReadOnly="True" Background="White" Height="22" />
                                        </Grid>
                                    </DataTemplate>
                                </telerikGV:GridViewColumn.CellTemplate>
                            </telerikGV:GridViewDataColumn>


                            <telerikGV:GridViewDataColumn UniqueName="Coupon"         IsReadOnly="True" Header="Coupon (%/yr)" Width="95">
                                <telerikGV:GridViewColumn.CellTemplate>
                                    <DataTemplate>
                                        <Grid>
                                            <uc1:NextFocusTextBox Text="{Binding Path=Bond.Coupon, Converter={StaticResource ValueConverterNumericDash}, ConverterParameter=0:N3}" BorderThickness="0" IsReadOnly="True" IsEnabled="{Binding IsEnabled}" />
                                        </Grid>
                                    </DataTemplate>
                                </telerikGV:GridViewColumn.CellTemplate>
                            </telerikGV:GridViewDataColumn>



    The code behind to produce the results is:

    private void mbToolBar_ExcelExportClicked(object sender, EventArgs e)
    {
        _printFileName                = "some_location" + MainPage.Username + ".xls";

        Uri uri                       = new Uri(_wcf.InnerChannel.Via.AbsoluteUri.Replace(_wcf.InnerChannel.Via.AbsolutePath, "/PrintHandler.aspx?FileName=" + _printFileName));

        WebClient client              = new WebClient();

        client.UploadStringCompleted += new UploadStringCompletedEventHandler(client_UploadExcelCompleted);

        client.UploadStringAsync(uri, BondGrid.ToHtml());

        BondGrid.IsBusy               = true;
    }

  2. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 22 Mar 2012 Link to this post

    Hello,

     The grid cannot export columns with defined CellTemplate. You should handle ElementExporting and assign e.Value to desired for these columns similar to our exporting demo. 

    Kind regards,
    Vlad
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Back to Top