how to remove link text for export to excel

6 posts, 0 answers
  1. diane
    diane avatar
    25 posts
    Member since:
    Oct 2010

    Posted 29 Sep 2011 Link to this post

    how to remove links from header text below. When I set ExportOnlyData="true"  the link is removed but the header text span tags shows in the excel header. Is there a way to edit the header text before exporting to excel.


    <telerik:RadGrid
                ID="RadGridReport"
                runat="server"
                CssClass="GridLines"
                ExportSettings-FileName="RadGridReportReport"
                AutoGenerateColumns="false"
                AllowPaging="false"
                AllowSorting="true"
                AllowFilteringByColumn="false"
                AllowMultiRowSelection="false"
                Enabled="true"
                Visible="false"
                OnGridExporting="RadGridReport_GridExporting"
                OnExcelExportCellFormatting="RadGridReport_ExcelExportCellFormatting">
                <ExportSettings OpenInNewWindow="true" />
                <MasterTableView AllowMultiColumnSorting="true"  AllowNaturalSort="false">
                    <HeaderStyle HorizontalAlign="Center" Font-Bold="true" />
                    <ItemStyle HorizontalAlign="Left" />
                    <AlternatingItemStyle HorizontalAlign="Left" />
                    <Columns>
                            <telerik:GridTemplateColumn UniqueName="Code" HeaderStyle-Width="15%">
                            <HeaderStyle CssClass="rgHeader hasNestedTable" />
                            <HeaderTemplate>
                                <table class="nestedHeaderTable" cellspacing="0" >
                                    <tr style="height:35%;">
                                        <th id="StateCode" colspan="2" align="center"><b>State Code</b></th>
                                    </tr>
                                    <tr style="height:65%;">
                                        <th id="Code" width="20%" align="center">
                                        <asp:LinkButton  ID="btnCode" Font-Underline ="true" ForeColor ="Blue" Text="Code <span  class = 'hidden'> Select to sort by Code</span>" ToolTip="Sort by Code" CommandName='Sort'  CommandArgument='Code' runat="server" /></th>
                                        <th id="Type" width="80%" align="center">
                   <asp:LinkButton  ID="btnType" Font-Underline ="true" ForeColor ="Blue" Text="Type <span  class = 'hidden'> Select to sort by Type</span>" ToolTip="Sort by Type" CommandName='Sort'  CommandArgument='Type' runat="server" /></th>
                                    </tr>
                                </table>
                            </HeaderTemplate>
                            <ItemStyle CssClass="hasNestedTable" />
                            <ItemTemplate>
                                <table class="nestedItemTable" cellspacing="0" >
                                    <tr>
                                        <td headers ="Code" width="20%" align="left" style="mso-number-format:\@;"><%# DataBinder.Eval(Container.DataItem, "Code")%></td>
                                        <td headers ="Type" width="80%" align="left"><%# DataBinder.Eval(Container.DataItem, "Type")%></td>
                                    </tr>
                                </table>
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>

     </Columns>
                </MasterTableView>
            </telerik:RadGrid>

  2. Jayesh Goyani
    Jayesh Goyani avatar
    2732 posts
    Member since:
    May 2010

    Posted 29 Sep 2011 Link to this post

    Hello,

    please check below code snippet for this.
    <ExportSettings ExportOnlyData="true"></ExportSettings>


    Thanks,
    Jayesh Goyani
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Alain
    Alain avatar
    6 posts
    Member since:
    Jan 2012

    Posted 19 May in reply to Jayesh Goyani Link to this post

    Hello,

    But what if I need to keep the controls for GridTemplateColumns. If I set the ExportOnlyData, I can not retriveve some values in the OnExcelExportCellFormatting event.

    If (e.FormattedColumn.UniqueName) = "Email" Then
        e.Cell.Width = 200
        Dim myEmail As String = ""
        myEmail = DirectCast((e.Cell.Controls(0)), System.Web.UI.WebControls.HyperLink).NavigateUrl.Replace("mailto: ", "")
        e.Cell.Text = myEmail

    endif

  5. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 24 May Link to this post

    Hi Alain,

    You can still use the ExportOnlyData property but manually set the header text like this:
     protected void btnExport_Click(object sender, EventArgs e)
        {
            RadGrid1.MasterTableView.GetColumn("ColumnUniqueName").HeaderText = "Your Custom Text";
      
            RadGrid1.ExportSettings.OpenInNewWindow = true;
            RadGrid1.ExportSettings.ExportOnlyData = true;
            RadGrid1.ExportSettings.IgnorePaging = true;
      
            RadGrid1.MasterTableView.ExportToExcel();
      
        }

    I hope this helps.

    Regards,
    Maria Ilieva
    Telerik
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  6. Alain
    Alain avatar
    6 posts
    Member since:
    Jan 2012

    Posted 24 May in reply to Maria Ilieva Link to this post

    Thank you,

    But When I set the ExportOnlyData, I have no access to template columns as here :

    myEmail = DirectCast((e.Cell.Controls(0)), System.Web.UI.WebControls.HyperLink).NavigateUrl.Replace("mailto: ", "")

    This is what I am asking for. How to get rid of the Hyperlinks, without havin to set the header names programmatically, but keeping the values of the template columns so I can set the ouput on the Export events.

    Truly.

     

  7. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 26 May Link to this post

    Hi,

    Currently this is the only possibility you have, to use the "ExportOnlyData" property and manually put the header text if needed.

    Regards,
    Maria Ilieva
    Telerik
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017